Is there an event or signal after the UI has been set
Hello,
I have QMainWindow with a QSplitter as the central widget, and the splitter has two QWidgets: top_widget and bottom_widget. I'd like to set the default size of bottom_widget to 100 on new, and allow this size to be saved and loaded. On Load I want to restore this value.
My question is: Where is the best place to set this default size to 100? Is there an event or signal the the QMainWindow receives after all children widgets have been positioned and resized?
Thank you!
Re: Is there an event or signal after the UI has been set
There are many possibilities, e.g. using invokeMethod() with Qt::QueuedConnection. Or you can do that the first time the widget is shown (using showEvent()). Or possibly using other means.
Re: Is there an event or signal after the UI has been set
In my apps I find it easiest to restore the window state in the showEvent() and to save it in the closeEvent(). You can also restore the state in the constructor if you wish, and it will be applied when the window is shown.
Re: Is there an event or signal after the UI has been set
Thank you! I'll try your suggestions. For the moment I am doing my stuff in the resize event only when the top and bottom widgets have size, and only once...
Re: Is there an event or signal after the UI has been set
Quote:
I am doing my stuff in the resize event
Better to do it in the show event. When this occurs, the widget (and its children) have been properly sized and positioned (by layouts), so you can safely examine their sizes and positions and resize or move them as you wish.
As you have probably seen, the resize event can be called multiple times, including when widgets have no sizes.