[PyKDE] problem with custom signals
eronlloyd at gmail.com
Mon Apr 17 03:32:00 BST 2006
On Wednesday 08 March 2006 4:35 am, Phil Thompson wrote:
> On Wednesday 08 March 2006 8:08 am, Emanuele Santos wrote:
> > Hi, Phil
> > I'm using the latest version of PyQt4 (20060306) and when I try something
> > like:
> > self.emit(QtCore.SIGNAL("mySignal(PyObject *)", myObject)
> > I get a type error, but if I use the short-circuited version
> > self.emit(QtCore.SIGNAL("mySignal"), myObject)
> > it works fine.
> > In your e-mail (couple weeks ago) I thought both ways were supposed to
> > work, am I correct?
> Yes, it's a bug. Will be fixed in tonight's SIP snapshot.
I'm trying to port code to PyQt4, and am having trouble implementing the new
signal/slot convention. I did my best to try and follow the previous list
discussions, but I still can't seem to get it to work. I wrote a test script
that provides the kind of behavior I'm needing, basically custom python
signals (and type arguments) passed to Qt built-in slots. I'm using SIP
4.4.1, yesterday's PyQt4 snapshot, and Qt 4.1.2. Thanks for any pointers!
from PyQt4.QtCore import *
from PyQt4.QtGui import *
a = QApplication()
w = QMainWindow()
m = QWidget()
l = QGridLayout(m)
t = QTreeWidget(m) # The "view" to be toggled
b1 = QPushButton("Enable", m)
b2 = QPushButton("Disable", m)
l.addWidget(t, 0, 0, 1, 2)
l.addWidget(b1, 1, 0)
l.addWidget(b2, 1, 1)
print "Enabling view..."
m.emit(SIGNAL("enableView"), True) # pass to t.setEnabled(True)
print "Disabling view..."
m.emit(SIGNAL("disableView"), True) # pass to t.setDisabled(True)
m.connect(b1, SIGNAL("clicked()"), enable)
m.connect(b2, SIGNAL("clicked()"), disable)
m.connect(m, SIGNAL("enableView"), t, SLOT("setEnabled(bool)"))
m.connect(m, SIGNAL("disableView"), t, SLOT("setDisabled(bool)"))
if __name__ == '__main__':
More information about the PyQt