window does not popup before process start -> tried sleep() method, but “fails”
Frage
I tried to use the sleep method before some processes start just to give a popup window the time to appear:
Processmethod()
{
QDialog *ProcessMessage = new QDialog;
Ui::DialogProcessMessage Dialog;
Dialog.setupUi(ProcessMessage);
ProcessMessage->setModal(true);
ProcessMessage->setAttribute(Qt::WA_DeleteOnClose);
ProcessMessage->show();
sleep(500);
PROCESSES START
}
My problem is, that the popup window just appears after the process is finished instead of before the process starts. If I deactivate the process that should start after the window appeared the popup window works fine.Are the processes responsible for the popup window fail? Where is my fault? greetings
Lösung
Add
qApp->processEvents();
before the sleep call.
Andere Tipps
I assume sleep
is Windows function? Do not use it. Use QTimer
to start process later:
ProcessMessage->show();
QTimer::singleShot(500, processObject, SLOT(start()));
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow