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

Torn off menus have no titlebar anymore, no way to close or move

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P1: Critical P1: Critical
    • None
    • 6.8.2, 6.8.3
    • GUI: Menus, QPA: Windows
    • None
    • Windows

      Menus which have the tearOffEnabled flag have no titlebar anymore when the menu got torn off. There is no way to close the torn off menu or to move it around.
      This worked in 6.5.3, but migrating our code to 6.8.2 or 6.8.3 shows the weird behavior.
      It looks like somehow the window flags get messed up, see attached flag comparison between 6.5 and 6.8.

      Repro code sample:

      int main( int argc, char *argv[] )
      {
          QApplication app( argc, argv );
          app.setQuitOnLastWindowClosed(true);
      
          // Create Top Level MainWindow
          auto mainWindow = new QMainWindow();
          mainWindow->setAttribute(Qt::WA_DeleteOnClose);
          mainWindow->setWindowTitle(QString("Tear-Off Menu Test - Qt%1.%2.%3").arg(QT_VERSION_MAJOR).arg(QT_VERSION_MINOR).arg(QT_VERSION_PATCH));
      
          // Add menu to main menubar
          auto testMenu = mainWindow->menuBar()->addMenu("Test Menu");
          testMenu->setTearOffEnabled(true);
          testMenu->addAction("Action 1");
          testMenu->addAction("Action 2");
      
          mainWindow->resize(800, 600);
          mainWindow->show();
      
          /* The issue can also be reproduced by mimicking what QMenu internally does 
          for creating the QTornOffMenu. */
          /*
          auto menuWithTitlebar = new QMenu();
          menuWithTitlebar->addAction("Action 1");
          menuWithTitlebar->setWindowTitle("Tear-Off Menu");
          menuWithTitlebar->setParent(mainWindow, Qt::Window | Qt::Tool); // <- this call doesn't seem to work as in the past
          menuWithTitlebar->setAttribute(Qt::WA_DeleteOnClose, true);
          menuWithTitlebar->show();
          */    
      
          // Run Qt message loop
          return app.exec();
      }

       

       

        1. NoTitlebarOnTearOff.png
          29 kB
          Roman Woelker
        2. TearOffMenu_WndFlagsCompare.png
          60 kB
          Roman Woelker
        3. image-2025-08-22-09-50-27-556.png
          106 kB
          SCAVARDO Christophe
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            roman_w Roman Woelker
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes