(Nov-24-2021, 01:45 PM)Axel_Erfurt Wrote: I can use the same code in PyQt5 and PyQt6
The only difference is
app.exec() / app.exec_()
from PyQt6.QtWidgets import QApplication, QMainWindow
from PyQt6 import uic
import sys
class Ui(QMainWindow):
def __init__(self):
super(Ui, self).__init__()
uic.loadUi('example.ui', self)
self.show()
app = QApplication(sys.argv)
window = Ui()
app.exec() # app.exec_() in PyQt5 #
they both can be used but I just want to load ui to self instead of self.ui
Still the problem of pyside loading ui this way is that it does not trigger closeEvent
because when you close the window, what you close is self.ui instead of self. So define a closeEvent in the class does not work.
self.ui should be a QMainWindow object but I don't know how to change the closeEvent of it
I tried to override the closeEvent of the QMainWindow class or define a closeEvent and pass it to self.ui.closeEvent but neither worked.