On 2/18/2007 6:13 PM, Phil Thompson wrote:
============================================== #!/usr/bin/env python from PyQt4.Qt import *a = QObject(None) called = [] def myslot(): called.append(True) QObject.connect(a, SIGNAL("destroyed()"), a, SIGNAL("QUIT")) QObject.connect(a, SIGNAL("destroyed()"), myslot) QObject.connect(a, SIGNAL("QUIT"), myslot) del a assert len(called) == 2, len(called) ============================================== This fails for me with PyQt 4.1.1 and SIP-snapshot-20061220 (the slot is invoked only once). I didn't test with newer SIP snapshots though.You need to add parenthesis to QUIT as you cannot connect Qt signals to short-circuit signals - connect() returns False.
Given that this feature is specific of SIP/PyQt, wouldn't it better to notify the mistake with an exception, rather than returning false? I don't think anybody ever checks the return value of connect (examples, tutorials, ecc.), so it's not a "common" practice (I wasn't even aware connect() *had* a return value...). The C++ version of connect() prints some spew on stderr when it fails: adding something like this would be also a good solution.
However there is a bug/feature that is fixed in tonight's PyQt snapshot.
Thanks! -- Giovanni Bajo _______________________________________________ PyKDE mailing list [email protected] http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
