[PyQt] QWidget 'destroyed' signal: possible regression?

Pierre Raybaut pierre.raybaut at gmail.com
Sun Feb 26 15:23:26 GMT 2012

Hi Phil,

I recently found out that a feature succesfully tested with older
versions of PyQt was broken
(http://code.google.com/p/spyderlib/issues/detail?id=951) and at the
same time the Matplotlib developers contacted me for a similar issue

To explain our problem, I wrote this test script:

from PyQt4.QtGui import QApplication, QWidget
from PyQt4.QtCore import Qt

def print_from_function():
    print "Callback = Function"

class TestWidget(QWidget):
    def __init__(self, parent=None):
        QWidget.__init__(self, parent)
        self.destroyed.connect(lambda: self.print_from_lambda_function())

    def print_from_method(self):
        print "Callback = method"

    def print_from_static_method(self):
        print "Callback = static method"

    def print_from_lambda_function(self):
        print "Callback = lambda function"

app = QApplication([])
widget = TestWidget()

The issue with the test script above is that all callbacks connected
to the 'destroyed' signal are triggered except for the callback which
is a method (bound to the object to be destroyed).

So the question is: is this a regression from PyQt v4.8.5? (or earlier)


More information about the PyQt mailing list