I have a widget which would have to do some manual cleanup after it's destroyed (stop some threads). However for some reason the "destroyed" signal of the widget is not firing. I have made this small example that demonstrates the problem.
import sys
from PyQt4 import QtGui
class MyWidget(QtGui.QWidget):
def __init__(self, parent):
super(MyWidget, self).__init__(parent)
def doSomeDestruction():
print('Hello World!')
self.destroyed.connect(doSomeDestruction)
class MyWindow(QtGui.QMainWindow):
def __init__(self):
super(MyWindow, self).__init__()
self.widget = MyWidget(self)
app = QtGui.QApplication(sys.argv)
window = MyWindow()
window.show()
ret = app.exec_()
sys.exit(ret)
I expected it to print "Hello World!" when the main window is closed. However, it doesn't print anything.