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

Restoring floating QDockWidget sets Qt::X11BypassWindowManagerHint

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.15.2
    • Widgets: Main Window
    • None
    • Arch Linux
    • Linux/X11

    Description

      Restoring a floating QDockWidget with QMainWindow::restoreDockWidget() unexpectedly sets the Qt::X11BypassWindowManagerHint flag on the QDockWidget window.

      The following example will reproduce the problem. Steps to reproduce:

      1. Run the example
      2. Click the "Show Dock Widget" button
      3. Close the main window (exits the example)
      4. Run the example again
      5. Click the "Show Dock Widget" button

      Expected results: Example prints nothing
      Actual results: Example prints "Qt::X11BypassWindowManagerHint was set!"

      QTBUG-78293 looks very similar but for QToolBar rather than QDockWidget.

      #include <QApplication>
      #include <QDockWidget>
      #include <QMainWindow>
      #include <QPushButton>
      #include <QSettings>
      
      class MainWindow : public QMainWindow
      {
      public:
          MainWindow()
          {
              QSettings settings("dock-app", "MainWindow");
              restoreGeometry(settings.value("geometry").toByteArray());
              restoreState(settings.value("windowState").toByteArray());
          }
      
          ~MainWindow()
          {
              QSettings settings("dock-app", "MainWindow");
              settings.setValue("geometry", saveGeometry());
              settings.setValue("windowState", saveState());
          }
      };
      
      int main(int argc, char ** argv)
      {
          QApplication app(argc, argv);
      
          MainWindow window;
          window.setWindowTitle("Main Window");
          window.show();
      
          QDockWidget widget(&window);
          widget.setObjectName("dock-widget");
          widget.setWindowTitle("Dock Widget");
      
          QPushButton button("Show Dock Widget");
          window.setCentralWidget(&button);
      
          QObject::connect(&button, &QPushButton::clicked, [&]() {
              if (!window.restoreDockWidget(&widget))
              {
                  window.addDockWidget(Qt::LeftDockWidgetArea, &widget);
                  widget.setFloating(true);
              }
      
              auto flags = widget.windowFlags();
              if (flags & Qt::X11BypassWindowManagerHint)
                  qWarning("Qt::X11BypassWindowManagerHint was set!");
      
              widget.show();
          });
      
          return app.exec();
      }
      

      Attachments

        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
            john.lindgren@aol.com John Lindgren
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes