How can I prevent a widget to become as small as the "small but still usable" size if there's enough space?
-
Hi all,
I have a
QDialog
with aQTabWidget
and a lot of widgets inside. The number of widgets and thus the needed vertical space is different. This leads to one of them being displayed vertically small, in the "small but still usable" mode:When I draw the dialog a bit taller, the style changes back to the "normal" mode:
There would be enough vertical space if the dialog was initialized a bit taller. I played around with
QSizePolicy
s, but the result is always the same.(How) Can I tell the widget to claim enough vertical space, so that it's big enough to not display that "tradeoff" style?
Thanks for all hints!
-
@l3u_ said in How can I prevent a widget to become as small as the "small but still usable" size if there's enough space?:
There would be enough vertical space if the dialog was initialized a bit taller.
(How) Can I tell the widget to claim enough vertical space,
These are quite different approaches. Which one do you actually want?
For individual widgets did you try
QSizePolicy::Fixed
? Docs say this is used for vertical on aQPushButton
so it does not shrink (or grow) vertically.For whole dialog you would have to set its size if you want it to be bigger, I don't think it will resize to accommodate non-shrunk content. Though I could be wrong.
If you just want a lazy but quick solution/workaround, if you are using a
QGridLayout
-type on your pages you could call void QGridLayout::setRowMinimumHeight(int row, int minSize). Though that's not the correct way to do things.I play with everything till I get what I want with Qt widgets and/or Designer, it's a dark art!
-
-
-
Actually, this does help … but it does not really fix it, depending on the font size used …
On my notebook, I have a 14" screen and thus use a bigger font (we're all not 20 anymore, are we?! ;-)
However, this is what I get there:
So, due to the bigger font, I still get that "smaller but still usable" top-bottom compression. When I resize the dialog, the widgets grow to the size they should have, but they won't grow larger:
So, we're back to the initial question … Despite
QSizePolicy::Fixed
set for the vertical size, the widget can shrink a bit smaller, causing this "small but still usable" compression for the combo and spin boxes – and clipping the label texts that contain line breaks.No matter what I do, I can't seem to prevent the clipping. Also doing
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed)
on each and every widget within the box does not change anything – I can still clip the label text and still "compress" the combo and spin boxes.What I also tried is to play with size constraints. When I do
setSizeConstraint(QLayout::SetMinimumSize)
on the box's layout, then the following happens:
The compression and clipping is gone – but now, the whole box is clipped instead :-( Resizing the dialog makes it visible again, and it also does not grow larger than the actually needed vertical size. But somehow, the layout thinks it does not need this space … either, it lacks inside the box, or outside of it …