[PyQt] Syntax for connecting to QGraphicsScene.changed signal?

TP wingusr at gmail.com
Thu Oct 14 23:37:02 BST 2010


QGraphicsScene's changed signal is documented as:

   void changed (const QList<QRectF>&)

The "Qt Utility classes and their Python equivalents" section of
"Chapter 10 Qt Class Hierarchy" of GUI Programming with Python: QT
Edition (from http://www.commandprompt.com/community/pyqt/x3738) says:
"You can always use a Python list wherever a QList is needed".

But defining a signal as:

   sceneChanged = QtCore.pyqtSignal(list)

and then doing:

   self._scene.changed.connect(self.sceneChanged)

results in the following exception:

   "TypeError: connect() failed between changed(QList<QRectF>) and
sceneChanged()"

As a workaround, I was able to do the following:

    @QtCore.pyqtSlot(list)
    def changed (self, rects):
        self.sceneChanged.emit(rects)

With the following connect() statement:

    self._scene.changed.connect(self.changed)

But how can I directly connect my signal to QGraphicScene's changed
signal without going through an intermediate python method?


More information about the PyQt mailing list