CmdForge/patches/UPSTREAM_ISSUE.md

2.0 KiB

PySide6 6.7+ Compatibility Issue: setSelectionArea API Change

Issue

When using NodeGraphQt-QuiltiX-fork with PySide6 6.7+, dragging a rubber band selection in the node graph causes repeated TypeError exceptions:

TypeError: 'PySide6.QtWidgets.QGraphicsScene.setSelectionArea' called with wrong argument types:
  PySide6.QtWidgets.QGraphicsScene.setSelectionArea(QPainterPath, ItemSelectionMode)
Supported signatures:
  PySide6.QtWidgets.QGraphicsScene.setSelectionArea(PySide6.QtGui.QPainterPath, PySide6.QtGui.QTransform)
  PySide6.QtWidgets.QGraphicsScene.setSelectionArea(PySide6.QtGui.QPainterPath, PySide6.QtCore.Qt.ItemSelectionOperation = Instance(Qt.ReplaceSelection), PySide6.QtCore.Qt.ItemSelectionMode = Instance(Qt.IntersectsItemShape), PySide6.QtGui.QTransform = Default(QTransform))

Root Cause

The QGraphicsScene.setSelectionArea() method signature changed in PySide6 6.7. The old signature allowed:

setSelectionArea(path, mode)  # mode = Qt.ItemSelectionMode

The new signature requires:

setSelectionArea(path, operation, mode)  # operation = Qt.ItemSelectionOperation

Affected File

NodeGraphQt/widgets/viewer.py line 524-526

Current Code

self.scene().setSelectionArea(
    path, QtCore.Qt.IntersectsItemShape
)

Fix

self.scene().setSelectionArea(
    path, QtCore.Qt.ReplaceSelection,
    QtCore.Qt.IntersectsItemShape
)

Environment

  • Python: 3.12
  • PySide6: 6.6.3.1 (installed by NodeGraphQt-QuiltiX-fork, but issue affects 6.7+)
  • NodeGraphQt-QuiltiX-fork: 0.7.0

Workaround

Apply this patch after installation:

# In viewer.py, change line 524-526 from:
self.scene().setSelectionArea(
    path, QtCore.Qt.IntersectsItemShape
)

# To:
self.scene().setSelectionArea(
    path, QtCore.Qt.ReplaceSelection,
    QtCore.Qt.IntersectsItemShape
)

This issue may also exist in:

  • Original NodeGraphQt
  • OdenGraphQt
  • Other forks

The fix is backward compatible with older PySide6 versions that support the 3-argument signature.