[PyKDE] Problem (re)connecting QWizard buttons
Ulrich Berning
ulrich.berning at desys.de
Fri Jun 24 11:16:17 BST 2005
Look at the following code:
(Yes, I know that reimplementing accept() is the better way)
---8<---------------------->8---
import sys
from qt import *
class MyWizard(QWizard):
def __init__(self,parent=None,name="",modal=False,fl=0):
QWizard.__init__(self,parent,name,modal,fl)
# Disconnect the default slot
self.disconnect(self.finishButton(),
SIGNAL('clicked()'),
self, SLOT('accept()'))
# With the lastest sip/PyQt snapshots,
# this additional reference is necessary
# *before* we connect to our own slot
# ---
# With sip-4.2.1/PyQt-3.14.1, this
# additional reference wasn't necessaray.
# Is this a bug or an intentional change?
self.fb = self.finishButton()
# Connect to our own slot
self.connect(self.finishButton(),
SIGNAL('clicked()'),
self.myFinishSlot)
def myFinishSlot(self):
print "myFinishSlot()"
self.accept()
if __name__ == "__main__":
a = QApplication(sys.argv)
QObject.connect(a, SIGNAL("lastWindowClosed()"),
a, SLOT("quit()"))
w = MyWizard()
w.show()
a.exec_loop()
---8<---------------------->8---
With the latest sip/PyQt snapshots, I have to store an additional
reference to the finishButton instance before I connect the signal to my
own slot, otherwise the slot gets never called.
With sip-4.2.1/PyQt-3.14.1 this additional reference wasn't necessary.
Is this a bug or an intentional change? I haven't found anything
specific in the ChangeLogs.
Ulli
More information about the PyQt
mailing list