Prevent QDockWidget Autosave Behavior

Qt 5.5.0

In my application, I have a QGraphicsView as the main widget and QDockWidget property. The goal is for the user to select an element in a graphical representation and, depending on the element, present the corresponding properties for that element.

I achieve this by having a property manager widget with a layout containing all property widgets. I have signals and slots connected to receive the currently selected element, and then show () the widget I need and hide () the rest.

It works great! However, when you select different elements, the dock shrinks or grows based on the widget shown. It is very annoying and quite annoying. The fact is that when the user manually resizes the dock, he supports this size. I want the supported size to be the default, and not this autosave behavior.


What I tried:

I tried changing the sizePolicy () of the dock and mainwindow: No effect.

I set a minimum size for my property manager, which really prevents the dock from shrinking when displaying a smaller set of properties. However, I still want the user to be able to compress the dock to a smaller size if they want it, and this method prevents this ...


Output:

-, , -, , ? , ?

QDockWidget QMainWindow. (), ?

!

+4
1

, ,

setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);

( QDockWidget)

sizeHint(), .

+3

Source: https://habr.com/ru/post/1622401/


All Articles