Qt Layout, resize to minimum after widget size changes

后端 未结 4 1676
自闭症患者
自闭症患者 2020-12-24 06:21

Basically I\'ve got a QGridLayout with a few widgets in it. The important ones are 2 labels, which I use for drawing images to the screen. Well, if the user wan

4条回答
  •  情书的邮戳
    2020-12-24 07:00

    You need to set the size constraint of the layout holding all your widgets to "SetFixedSize". Although the name doesn't sound like it will work, it ensures that your layout will only use the space it needs. You will not have the problem like you do in your second screenshot.

    Example:

    mainLayout.setSizeConstraint(QLayout::SetFixedSize);
    

提交回复
热议问题