*** GMX Spamverdacht *** [PyQt] pyqt4 signal/slot using PyObject* and shortcut

Andreas Pakulat apaku at gmx.de
Fri Apr 27 15:45:08 BST 2007


On 27.04.07 11:30:04, Pradnyesh Sawant wrote:
>    def run(self):
>        cntr = 0
>        while cntr < 10:
>            cntr += 1
>            self.emit(QtCore.SIGNAL("showCntr1(PyObject*)"), (cntr,
> "a"))   # line 1
>            self.emit(QtCore.SIGNAL("showCntr2"), (cntr, "a"))
>          # line 2
>            time.sleep(0.2)
...
> if __name__ == "__main__":
>    app = QtGui.QApplication(sys.argv)
>    dialog = Gui()
>    cntr = Counter()
>    cntr.start()
>    QtCore.QObject.connect(cntr, QtCore.SIGNAL("showCntr1(PyObject*)"),
>            dialog.showCntr1, QtCore.Qt.QueuedConnection)
>    QtCore.QObject.connect(cntr, QtCore.SIGNAL("showCntr2"),
>            dialog.showCntr1, QtCore.Qt.QueuedConnection)
>    sys.exit(dialog.exec_())
> #################################################################
> If i comment out "line 1", then i get the following output:

You don't keep a reference to the object that you send via the signal.
You need to do that, as a queued connection behaves different from a
direct connection (which is a direct function call). Thats why you see
all kinds of weird results.

I couldn't make the line 1 work though, it always tells me that argument
0 of the signal has an invalid type.

Andreas

-- 
Don't hate yourself in the morning -- sleep till noon.


More information about the PyQt mailing list