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. error panel goes underneath floating window, causing confusion

error panel goes underneath floating window, causing confusion

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 416 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.
  • B Offline
    B Offline
    bhaller
    wrote on last edited by
    #1

    Hi folks. I've got a QWidget-based desktop application that's cross-platform on macOS, Windows, and Linux. There's a glitch that I'm not sure how best to fix: an error panel can open underneath a floating window. When this happens, the app appears to lock up, because the error panel has focus and won't give it up, but at the same time, it is not visible to the user. They can move the floating window aside to reveal the error panel, but that requires that they realize what is happening, and it is very far from obvious – it took a while to figure out what was happening from the user reports!

    The floating window is created like so:

    QWidget *graphWindow = new QWidget(this, Qt::Window | Qt::Tool);
    ...
    graphWindow->show();
    graphWindow->raise();
    graphWindow->activateWindow();
    

    The "..." is just adding some elements inside the window and such; nothing particularly fancy is going on. I think probably the only important thing here is that Qt::Tool is used as a window attribute, making the window float.

    The error panel is created like so:

    QMessageBox messageBox(this);
    messageBox.setText("Simulation Runtime Error");
    messageBox.setInformativeText(fullMessage);
    messageBox.setIcon(QMessageBox::Warning);
    messageBox.setWindowModality(Qt::WindowModal);
    messageBox.setFixedWidth(700);      // seems to be ignored
    messageBox.exec();
    

    It seems like either (1) the error panel should float at a higher level than the Qt::Tool window, or (b) Qt::Tool windows should automatically hide when an error panel is up. One way or another, the error panel should always be visible to the user, since it is modal. But at least on macOS, that is not the case, and so the app seems to the user to be locked up, and the user decides they have to force-quit the app.

    I imagine that others must have confronted this problem, since both floating Qt::Tool windows and error panels are presumably common. So, has somebody found a good solution for this problem that they can share? Am I doing something wrong in my configuration of the windows that is causing this to occur? Is there a straightforward workaround? Thanks!

    Pl45m4P 1 Reply Last reply
    0
    • B bhaller

      Hi folks. I've got a QWidget-based desktop application that's cross-platform on macOS, Windows, and Linux. There's a glitch that I'm not sure how best to fix: an error panel can open underneath a floating window. When this happens, the app appears to lock up, because the error panel has focus and won't give it up, but at the same time, it is not visible to the user. They can move the floating window aside to reveal the error panel, but that requires that they realize what is happening, and it is very far from obvious – it took a while to figure out what was happening from the user reports!

      The floating window is created like so:

      QWidget *graphWindow = new QWidget(this, Qt::Window | Qt::Tool);
      ...
      graphWindow->show();
      graphWindow->raise();
      graphWindow->activateWindow();
      

      The "..." is just adding some elements inside the window and such; nothing particularly fancy is going on. I think probably the only important thing here is that Qt::Tool is used as a window attribute, making the window float.

      The error panel is created like so:

      QMessageBox messageBox(this);
      messageBox.setText("Simulation Runtime Error");
      messageBox.setInformativeText(fullMessage);
      messageBox.setIcon(QMessageBox::Warning);
      messageBox.setWindowModality(Qt::WindowModal);
      messageBox.setFixedWidth(700);      // seems to be ignored
      messageBox.exec();
      

      It seems like either (1) the error panel should float at a higher level than the Qt::Tool window, or (b) Qt::Tool windows should automatically hide when an error panel is up. One way or another, the error panel should always be visible to the user, since it is modal. But at least on macOS, that is not the case, and so the app seems to the user to be locked up, and the user decides they have to force-quit the app.

      I imagine that others must have confronted this problem, since both floating Qt::Tool windows and error panels are presumably common. So, has somebody found a good solution for this problem that they can share? Am I doing something wrong in my configuration of the windows that is causing this to occur? Is there a straightforward workaround? Thanks!

      Pl45m4P Offline
      Pl45m4P Offline
      Pl45m4
      wrote on last edited by
      #2

      @bhaller said in error panel goes underneath floating window, causing confusion:

      messageBox.setWindowModality(Qt::WindowModal)

      Hi, try Qt::ApplicationModal here.
      Then the dialog box should appear above every other window.
      But I'm not sure how the Tool flag behaves in combination with other modal windows. AFAIK the Tool Window only does actual stuff / has an actual effect on MacOS. For the other systems it's like a regular popup.


      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      1 Reply Last reply
      1
      • B Offline
        B Offline
        bhaller
        wrote on last edited by
        #3

        Thank you, that change does fix the window level problem! :->

        Qt::Tool seems to at least do no harm on other platforms. I mostly develop and test on macOS, so I'd have to check on the other platforms to confirm for sure, but nobody has complained about that. :-> Anyhow, Qt::ApplicationModal solves the immediate problem, thanks!

        1 Reply Last reply
        0
        • B bhaller has marked this topic as solved on

        • Login

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