QSplitter collapses widget directly when the widget size is below a given size
-
Hello, in my MainWindow, I have a spliter in which I placed two widgets (see the picture below)
Currently, when a suer resize the blue part, its size goes to 0 and the the QSplitter collapses the blue widget.
I tried to use setCollapsible(false) for the blue widget but in that case, the widget is not collapsed anymore ; it stops resizing below a minimum size.What I would like is the blue widget cannot be smaller than the "minimum size before collapsing" shown on the picture and if the user continue to resize lower, then the widget collapse. Another way to say is I would like the collapsing happens if the widget size is smaller than a given size.
Any idea?
-
@Gojir4
Here is what I have so farint appWidth = QGuiApplication::primaryScreen()->virtualSize().width(); ui->splitter->setSizes(QList<int>({appWidth*2/3 , appWidth*1/3})); ui->blue_area->setMinimumWidth(200); ui->blue_area->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Expanding);
Unfortunately, it does not change anything. Actually, the widget collapses directly when its width is smaller than 50 pixels. But I do not have any 50 pixels in my code.
-
@odelaune Not sure but if the QTabWidget is empty it may have a sizeHint of 0, maybe it has "priority" over minimumSize. Hard to say without testing. So I would test with simple QWidget instead of QTabWidget to see if there is a difference. What I'm doing usually in this case is making some experiment in the Qt designer until I find the good configuration.
-
Some news. I played with Qt Designer and it appears that my custom widget (blue part) has a good behaviour when I set a minimum width for it with setMinimumWidth(), i.e. it collapses when its width becomes smaller than the minimum width . Yet, when I place this custom widget in a QTabWidget, then I have my initial problem, i.e. the blue part (that is now a QTabWidget) collapses only when its width becomes smaller than 50 pixels, even if I set its minimum width to 200 pixels.