Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Forcing a QDockWidget to behave like a central widget when it comes to resizing
pbe last edited by pbe
I am using dock widgets without a central widget (
setCentralWidget(Q_NULLPTR)) for QOwnNotes (C++, Qt5), because you can have more complex layouts without a central widget.
My problem is that if the user resizes the application main window some more or less random dock widgets will be resized. It would be more desirable to set one specific dock widget to be resized (like the center widget would behave).
Example of the current behavior:
The left area gets resized, it would be much better if the right area (note preview in this case) would get resized.
Is there a way to force a
QDockWidgetto behave like a central widget when it comes to resizing the main window without actually using a central widget?
I already tried to use
sizePolicy.setHorizontalPolicy, but it didn't get me there...
JonB last edited by JonB
I already tried to use sizePolicy.setHorizontalPolicy, but it didn't get me there...
A QDockWidget acts as a wrapper for its child widget, set with setWidget(). Custom size hints, minimum and maximum sizes and size policies should be implemented in the child widget. QDockWidget will respect them, adjusting its own constraints to include the frame and title. Size constraints should not be set on the QDockWidget itself, because they change depending on whether it is docked; a docked QDockWidget has no frame and a smaller title bar.
pbe last edited by
@JonB, thank you for answering,
A QDockWidget acts as a wrapper for its child widget
Yes, I'm aware of that and I also tried everything with the child widget itself.
That's about limiting min and max width, right? It wouldn't help in my case since the user still needs to be able to resize the dock widgets.
JonB last edited by
I'm no expert. Both links were meant to indicate that the examples talk about having to do the resizing on the contained widgets rather than on the containing docker.