QDockWidgetGroupWindow effectively sets new dockarea permissions on qdockwidget
-
I have the following situation, tested also in minimal qt code in Creator:
- create mainwindow and two dockwidgets A and B and enable all dockwidget features
- set both dockwidgets allowed areas to one location only, RightDockWidgetArea for example
- dock both them
- now drag A out to float
- drag B to float, but do not drop it, move it over A temporily and move it back to where it was, never dropping the dockwidget - A now has the hidden class object QDockWidgetGroupWindow as its parent, and its permissions are all messed up, it can dock anywhere .. .this is a problem for me and i need to get rid of it ... i tried watching for featureChanged event, but it is never called on the original dockwidget, its permissions are fine, but it seems the new parent causes this issue .. the problem is dockwidget A is only allowed in right area, but after this mouse manuever, it can go anywhere .. please help
#include "mainwindow.h" #include <QApplication> #include <QDockWidget> #include <QIcon> #include <QHBoxLayout> #include <QGridLayout> #include <QDebug> class MyDW : public QDockWidget { public: explicit MyDW(QWidget *parent): QDockWidget(parent, Qt::WindowFlags()) { setMouseTracking(true); w = dynamic_cast<QMainWindow *>(parent); } virtual ~MyDW() {} protected: QMainWindow *w; virtual void mousePressEvent(QMouseEvent *event) override { } }; int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow outer; outer.show(); outer.centralWidget()->setLayout(new QGridLayout); outer.centralWidget()->layout()->setContentsMargins(0,0,0,0); outer.centralWidget()->setMinimumSize(0,0); outer.setDockOptions(QMainWindow::AllowTabbedDocks | QMainWindow::GroupedDragging); // | QMainWindow::AllowNestedDocks); MyDW *d1 = new MyDW(&outer); d1->setWindowTitle("blue"); d1->setFeatures(QDockWidget::AllDockWidgetFeatures); d1->setAllowedAreas(Qt::DockWidgetArea::LeftDockWidgetArea); MyDW *d2 = new MyDW(&outer); d2->setWindowTitle("red"); d2->setFeatures(QDockWidget::AllDockWidgetFeatures); d2->setAllowedAreas(Qt::DockWidgetArea::RightDockWidgetArea); d1->show(); d2->show(); outer.addDockWidget(Qt::DockWidgetArea::LeftDockWidgetArea, d1); outer.addDockWidget(Qt::DockWidgetArea::RightDockWidgetArea, d2); return a.exec(); }
-
Hi,
Which version of Qt ?
On which OS ? -
ok i think i have a workaround, but i still would like to know if there is a native Qt solution - this was a real pain for some time, only today i just found a solution but it is not ideal
Big Sur and Qt v 5.15 in Creator
I would attach a video but i am not allowed here it seems .. hpoefully the descr makes sense
-
in fact, now i see there is still an issue, that the combination of floating qdockwidgets can be docked anywhere .. i cannot allow this but there is no way i know of to set these permissions on the hidden class object, which is not accessible ... seems to be a major bug in this system? please advise
-
follow-up: can i set any docking permissions at all (even disable) on the group/combined dockwidgets inside QDockWidgetGroupWindow? it seems it does not respect the mainwindow settings either .. for example nested is allowed on the group even if disabled normally
-
Looks like you may have found a bug.
You should check the bug report system to see if there's something about it.
Just in case there are other docking solution like KDAB's KDDockWidgets.
-
It's a bug and we are working at it here.
-
Fixed in 6.3, 6.2 and 15.5. Thanks for bringing this up.