passing tuple with pyqt4 signal/slot mechanism

Pradnyesh Sawant spradml at gmail.com
Thu Apr 26 11:49:43 EDT 2007


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?

> > The output i'm getting is as follows:
> >
> > tpl: ('Primary', 'priSec')
> > ####tpl: (<refcnt 0 at 0xb7caac8c>,)
> > **********tpl: ((((((((<NULL>,),),),),),),),)
> >
> Works for me in that the setLabel() isn't executed at all - but then you are
> emitting the signal before connecting it. Also my crystal ball isn't telling
> me what versions you are using or what platform you are on.
>
> Phil
>
>
-- 
warm regards,
Pradnyesh Sawant
--
Be yourself, everyone else is taken. --Anon



More information about the Python-list mailing list