Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Different behavior of QMessageBox in Mac that in Windows
Qt 6.11 is out! See what's new in the release blog

Different behavior of QMessageBox in Mac that in Windows

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 525 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    maria.v
    wrote on last edited by
    #1

    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
    
    
    }
    
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved