Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QDockWidget doesn't resize after add widget
I'm using a QDockWidget in MainWindow. When I insert a widget (in my case a table) into the dock, it does not expand with the widget, but it expands to a fixed size and then the scrollbar appears.
However, if the widget is smaller than this initial fixed size, the Dock fits.
But I didn't set any minimum or maximum size.
Here is the dock code:
QDockWidget *pPropertyDock = new QDockWidget(this); pPropertyDock->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable); pPropertyDock->setAllowedAreas(Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea); pPropertyDock->setWindowTitle(DOCK_TITLE); pPropertyDock->setObjectName(DOCK_OBJECTNAME); addDockWidget(Qt::RightDockWidgetArea, pPropertyDock);
According to what the documentation says, the Dock should be adapted to the child widget.
I do not understand where this maximal initial width comes from.
Anyway I can extend it by hand, but I would like to extend in automatic.
I hope I explained myself
@Gianluca86 Is your dock widget in a layout?
I hope not to misunderstand the question, but anyway no, I created the Dock inside the Mainwindow (addDockWidget (Qt :: RightDockWidgetArea, pPropertyDock)), while in the mainWindow centralWidget there is another widget.
To insert the table into the Dock I simply used the command "setWidget" of QDockWidget.
For more information:
the "Dock Widgets Example" show the problem.
Im not sure i understand.
So the issue is that the dock is smaller than the QListWidget?
The dock seems to have the size from the area allocated when created.
Since there it no way it can adjust the splitter or the mainwindow size, how would it grow to fit the widget?
So there is no way to adjust the area where the dock is allocated?
Can you do it only by hand?
You can make main window bigger and move the splitter. then
it should be bigger.