I’m wondering if it is possible to capture an event that is generated when all
Qt objects are initialized and ready ?
It seems that some things can’t be done in window’s constructor. And they work fine in slot implementation.
For example, when I want to access root window of my application I do it like that
// in *.h
MainWindow* rootWindow
// in *.cpp
rootWindow = qobject_cast<MainWindow *>(this->window());
If it is done in the contructor I can’t use rootWindow object – it couses runtime error.
There is no relevant slot to implement. And create event in QMainWindow class is not virtual.
Thanks for help 🙂
You can use a single-shot timer for this. In your main window class, define a slot function called say,
appReady(). In the constructor, create and connect a single shot timer usingQTimer::singleShot(0, this, SLOT(appReady()));This timer should fire as soon as the event loop is up and running and there are no more startup events pending.