Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-84208

window is sent to back of all other windows in the OS if its child dialog which has another child dialog is deleted

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.9.9, 5.15.0 RC2
    • None
    • Windows 10 Pro 64-bit
    • Windows

    Description

      I have a main window A which opens a child dialog B and this child dialog opens another child dialog C (i.e. a grandchild of the main window). Then the dialog B is deleted. This deletes also dialog C, which is correct AFAIK. But the problem is that after this, the main window is automatically sent to back of other windows which are currently open on the desktop.

      My code:

      #include <QApplication>
      #include <QDialog>
      #include <QTimer>
      
      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
          QWidget windowA;
          windowA.show();
      
          auto dialogB = new QDialog(&windowA);
          dialogB->show();
      
          auto dialogC = new QDialog(dialogB);
          dialogC->show();
      
          QTimer timer;
          timer.setSingleShot(true);
          timer.start(1000);
          QObject::connect(&timer, &QTimer::timeout, dialogB, &QDialog::deleteLater);
      
          return a.exec();
      }
      

      To sum up the outcome: the main window A is still existing but disappears and gets hidden behind other windows of other processes. This is quite unexpected.

      Expected result: main window A is visible as it was before deleting its children.

      PS: This might seem as a very artificial example. My use case is however quite natural. Dialog B represents a progress dialog of a background thread. This dialog has "abort" button in it. Pressing this button will open a question dialog asking "do you really want to abort this task?". But when the background task is finished while dialog C is still open, then dialogs get destroyed. And main window disappears behind other windows.

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              qt.team.quick.subscriptions Qt Quick and Widgets Team
              vladimir.kraus Vladimir Kraus
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes