Resize QDialog at a runtime

左心房为你撑大大i 提交于 2019-12-18 13:34:19

问题


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?

回答1:


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.



来源:https://stackoverflow.com/questions/24693181/resize-qdialog-at-a-runtime

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!