Exec() QDialog after MainWindow appears
-
03-06-2021 - |
Pregunta
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.
Solución
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()
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow