I would like to show a label and execute a function after displaying the label. Unfortunately, the label is always displayed after the function is executed.
void MainWindow::showLabel(){
myLabel->show();
doSomething();
}
void MainWindow::doSomething(){
QThread::msleep(3000);
myLabel->hide();
}
So, when i execute my code, the programm waits for three seconds and does show me an empty window afterwards (since it directly hides the label before even showing it; if I comment the hide function, the label is shown after waiting three seconds). What I've tried to do is modifying the showEvent like this:
void MainWindow::showEvent(QShowEvent *event) {
QMainWindow::showEvent(event);
doSomething();
}
Am I doing something wrong by modifying the method or is there any other way to show the label before executing the followed function?