I have a QDialog subclass containing some options of my application. Some of the options are core, the other are advanced, so I decided to put them into separeted checkable QGroupBox.
I want my dialog to shrink verticaly when the user checked off advanced options box, but I can't find the way to do it properly - the dialog size stays exactle the same
I set dialog's size policy to Expanding, tried to call adjustSize()
and tried to call resize()
method - nothing helps. I can't resize programmaticaly dialog to be smaller then it's current size (it only can become larger). At the same time, it is possible to resize it manualy.
Can anybody help me?
Resize QDialog at a runtime
Asked Answered
If you don't need manual resize, you can add
layout()->setSizeConstraint(QLayout::SetFixedSize);
to the dialog constructor, then the layout takes over the responsibility to automatically resize when widgets are shown or hidden.
This saves a ton of headache trying to manage ui sizing, Thanks. –
Chuffy
© 2022 - 2024 — McMap. All rights reserved.
adjustSize()
should do the job. How do you hide those additional widgets and how do you restore them? – BadrsizeHint()
, because it still thinks it has widgets to be contained and displayed. After removing them, calladjustSize()
on dialog. – BadrPreferred
? I think it should fit better for this case. – BadrPreferred
, but unfortunately it doesn't help – Cadmus