passing tuple with pyqt4 signal/slot mechanism
Phil Thompson
phil at riverbankcomputing.co.uk
Thu Apr 26 12:00:46 EDT 2007
On Thursday 26 April 2007 4:49 pm, Pradnyesh Sawant wrote:
> Thanks for the reply Phil. Actually, as mentioned earlier, the code
> that i sent was stripped; while stripping, i missed some things (class
> D should have a run method). Also, i tried your suggestion of
> connecting before emitting the signal, but am still getting the same
> output (in the original code). the modified code is given below:
>
> class D(QtCore.QThread):
> def __init__(self):
> QtCore.QThread.__init__(self)
> def run(self):
> tpl = ("Primary", "priSec")
> print "tpl:", tpl
> self.emit(QtCore.SIGNAL("setLabel"), tpl)
> class Gui(QtGui.QDialog):
> def __init__(self, parent = None):
> QtGui.QDialog.__init__(self, parent)
> def setLabel(self, tpl):
> print "####tpl:", tpl
> print "**********tpl:", str(tpl)
> if __name__ == "__main__":
> app = QtGui.QApplication(sys.argv)
> dialog = Gui()
> d = D()
> QtCore.QObject.connect(d, QtCore.SIGNAL("setLabel"),
> dialog.setLabel, QtCore.Qt.QueuedConnection)
> d.start()
> sys.exit(dialog.exec_())
>
> Also, in the modified code, why aint the method setLabel getting called?
Works for me, and I still don't know what versions you are using and on which
platform. Whatever they are, try the latest release.
Phil
More information about the Python-list
mailing list