0

I want to make a Modal QDialog appear (with exec()) after the MainWindow appears itself.

I tried to call exec in MainWindow::showEvent ( QShowEvent * event ) but It still show before the MainWindow appears.

Any idea how could achieve this ?

thx.

Matthieu Riegler
  • 31,918
  • 20
  • 95
  • 134

1 Answers1

3

The problem is that your showEvent() doesn't return since exec() is a blocking call.

I would suggest you use QDialog::open() instead, which opens a modal dialog but is a non-blocking function call. Thus:

MainWindow::showEvent( QShowEvent* )
{
    launchWidget->open();
}

Note that normal execution of your program continues when calling open()

Chris
  • 17,119
  • 5
  • 57
  • 60