Solved Limit the bottom dockwidget area size
-
I'm building an image editor with the classic thumb view (in a QListView) in a QDockWidget (thumbDock). When the user drags the thumbDock to the bottom of the window I set QListView->wrapping to false and resize the thumbDock height to fit the thumbnail height.
If the dock area is resized by the user grabbing the separator between the bottom dock and the central window I resize the thumbnails to fit as the dock is "stretched".
When using the separator between the central widget and the thumbDock in the bottom dock widget area I do not want the dock resized larger than the maximum height of my thumbnails (160 pixels). I can monitor the resize via the eventFilter, filtering events for resize and thumbDock, and then for only the bottom dock area and height, but I do not know how to prevent resizing exceeding my maximum thumbnail height.I do not want to control the dock area dimensions in any of the other dock areas.
Any suggestions would be greatly appreciated. Thanks in advance.
-
@Rory_1
From this post, it seems that you need to set size hints on the contents of the DockWidget, not on the Dockwidget itself.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
So you could set the sizehints of the thumbnail differently when the dock is docked.
-
Thanks. I'll work on that and mark this as resolved.
-
I really appreciate the help. My QListView is called thumbView. This worked:
thumbView->setMaximumHeight(160);
-
@Rory_1
Great! Thanks for the feedback! I'm also just discovering (and sometimes learning the hard way) the powerful Qt framework, and I'm glad I could help.