Forcing a QDockWidget to behave like a central widget when it comes to resizing
-
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
QDockWidget
to 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... -
I already tried to use sizePolicy.setHorizontalPolicy, but it didn't get me there...
http://doc.qt.io/qt-5/qdockwidget.html#details:
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.
?
?
-
@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.