I do not understand anything about Qt Designer . I have been working with it for a while, and yet I always edit .ui files manually.
As you can see from each Qt tutorial, one of the first things you do when creating a GUI is a subclass of QMainWindow , for example, to intercept and override the closeEvent() function.
However, in Qt Designer it is not possible to subclass ("promote") QMainWindow - you can do this with many other classes, but not with this.
What I usually do is edit the .ui file and change:
<class>MainWindow</class> <widget class="QMainWindow" name="MainWindow">
by:
< widget class="MyMainWindow" name="MainWindow">
So, my code can subclass QMainWindow correctly in my code:
class MyMainWindow(QMainWindow, object): ''' I can redefine closeEvent here! '''
Obviously, this is strange - and I probably missed something about the right way to do this with Designer. But I can not find any explanation.
Why is this not possible in a subclass of QMainWindow in Designer, or how to structure my application differently to avoid its need?
thanks
maxime-esa
source share