How can i check if QMainWindow is fully loaded ?
-
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!!!