Unsolved Different behavior of QMessageBox in Mac that in Windows
-
I have this code that shows a pop up with a message while a time-consuming operation runs. When the operation ends the message dissapear.
This works fine in mac but in Windows, the pop up appears and disapears inmediatly.
How can I fix this?
void myMainWindow::loadingModal(QString msg) { QMessageBox msgBox(pqCoreUtilities::mainWidget()); msgBox.setText("<p align='center'>" + msg + "</p>"); msgBox.setStandardButtons(0); msgBox.setStyleSheet("margin-right: 20px;" "margin-top: 20px;" "color: rgb(72, 66, 66);" "font-family: NunitoSans-SemiBold;" "font-size: 14px;" "font-weight: 600;"); msgBox.show(); pqEventDispatcher::processEventsAndWait(100); } void myMainWindow::btn_calculate_pressed() { // code loadingModal("Wait until calculation ends.") // time-consuming task starts }
-
Hi,
It's just sheer luck that it is working on macOS and I would even go further saying it's a bug.
The call to show is not blocking hence you reach the end of the method and msgBox gets destroyed so you won't see it.