I'm having a problem with the closeEvent() function override in a class which is not triggering. This is the code I have in the main.py file:
from mainwindow import *
if __name__ == '__main__':
app = QApplication()
mainwindow = QMainWindow()
window = Ui_MainWindow()
window.setupUi(mainwindow)
mainwindow.show()
app.exec_()
And then in another file named mainwindow.py I have:
class Ui_MainWindow(QMainWindow):
def setupUi(self, MainWindow):
.......
def retranslateUi(self, MainWindow):
........
def closeEvent(self,event):
print("Testing")
But when I close the window the closeEvent() function never runs. I'm missing something or doing it wrong but I can't figure out what it is. Please help.