passing tuple with pyqt4 signal/slot mechanism

P

Pradnyesh Sawant

Hello,
I have a pyqt4 code in which i'm trying the signal/slot mechanism. The
(stripped) code is as follows:

class D(QtCore.QThread):
def __init__(self):
QtCore.QThread.__init__(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)
return
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
dialog = Gui()
d = D()
QtCore.QObject.connect(d, QtCore.SIGNAL("setLabel"),
dialog.setLabel, QtCore.Qt.QueuedConnection)
sys.exit(dialog.exec_())

The output i'm getting is as follows:

tpl: ('Primary', 'priSec')
####tpl: (<refcnt 0 at 0xb7caac8c>,)
**********tpl: ((((((((<NULL>,),),),),),),),)

Can anyone kindly tell me what's happening here? Why is the tuple
("Primary", "priSec") getting converted to this <NULL> thingy? And
what is this thingy anyways (It looks to be a deeply nested tuple, but
am not sure).

Thanks a lot!
 
D

Diez B. Roggisch

Pradnyesh said:
Hello,
I have a pyqt4 code in which i'm trying the signal/slot mechanism. The
(stripped) code is as follows:

class D(QtCore.QThread):
def __init__(self):
QtCore.QThread.__init__(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)
return
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
dialog = Gui()
d = D()
QtCore.QObject.connect(d, QtCore.SIGNAL("setLabel"),
dialog.setLabel, QtCore.Qt.QueuedConnection)
sys.exit(dialog.exec_())

The output i'm getting is as follows:

tpl: ('Primary', 'priSec')
####tpl: (<refcnt 0 at 0xb7caac8c>,)
**********tpl: ((((((((<NULL>,),),),),),),),)

Can anyone kindly tell me what's happening here? Why is the tuple
("Primary", "priSec") getting converted to this <NULL> thingy? And
what is this thingy anyways (It looks to be a deeply nested tuple, but
am not sure).

It's just wild guessing back from my Qt3-days - but isn't PYSIGNAL
instead of SIGNAL necessary here?

Diez
 
P

Phil Thompson

It's just wild guessing back from my Qt3-days - but isn't PYSIGNAL
instead of SIGNAL necessary here?

No, PyQt4 used SIGNAL for both Qt and Python signals.

Phil
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,139
Latest member
JamaalCald
Top