I have a QDialog, where i create a QTimer Object, which triggers every n seconds a function. After closing the Dialog (hitting the x button), the timer is still firing and seems to be not destroyed. How can i stop it? Currently as a workaround i am explicitly calling Qtimer.stop() when entering the closeEvent()?
I would expect that every class-member is deleted, when the Window is closed, even when i call the Deconstructor explicitly, the Qtimer object persists.
from PyQt4 import QtGui, QtCore
import sys
def update():
print "tick..."
class Main(QtGui.QDialog):
def __init__(self, parent = None):
super(Main, self).__init__(parent)
self.timer = QtCore.QTimer()
self.timer.timeout.connect(update)
self.timer.start(2000)
# scroll area
self.scrollArea = QtGui.QScrollArea()
self.scrollArea.setWidgetResizable(True)
# main layout
self.mainLayout = QtGui.QVBoxLayout()
self.setLayout(self.mainLayout)
def closeEvent(self, evt):
print "class event called"
self.timer.stop()
myWidget = Main()
myWidget.show()