How can i check if QMainWindow is fully loaded ?
-
What do you want to do with that signal?
The UI is fully set up once the constructor of your mainwindow is done. It is save to just place all your custom code either into the constructor of your mainwindow class or right after the object is constructed.
There is no delay to download images and code, etc. that you see when programming web apps, so on load behavior is not really that useful in a Qt UI in my experience.
-
Reimplement the event method and check if the event is the polishEvent.
@bool MainWindow::event(QEvent *event)
{
int returnValue = QWidget::event(event);if (event->type() == QEvent::Polish)
{
QSize widgetSize = this->size(); // store widget size
return true;
}return returnValue;
}@ -
I had a similar problem and I used a QTimer::singleshot() with a timeout of 0 seconds. So my timer event was the first to fire after the app was in event loop (i.e. u can safely assume the app was loaded and was being displayed to the user ).
-
showEvent() is the right place to do these things.
Don't forget to remember that you've initialized it in a bool member, otherwise you will re-initialize it every time your main window is shown again.
Sample:
@
void yourMainWindow::showEvent( QShowEvent *event )
{
// call whatever your base class is!
QDialog::showEvent( event );
if( event->spontaneous() )
return;if(isInitialized) return; // do your init stuff here isInitialized = true;
}
@Don't forget to set isInitialized to false in your constructor!
-
[quote author="Volker" date="1307434864"]showEvent() is the right place to do these things.
Don't forget to remember that you've initialized it in a bool member, otherwise you will re-initialize it every time your main window is shown again.
Sample:
@
void yourMainWindow::showEvent( QShowEvent *event )
{
// call whatever your base class is!
QDialog::showEvent( event );
if( event->spontaneous() )
return;if(isInitialized) return; // do your init stuff here isInitialized = true;
}
@Don't forget to set isInitialized to false in your constructor![/quote]
I used code like this to ask the user if wants to load the last played song using a QMessageBox,
but the question is shown before the main window. How could I know when the main window is completely visible?Tnxs!!!