Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.15.2
-
None
-
Arch Linux
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(); }