Qt Layout, resize to minimum after widget size changes

后端 未结 4 1651
自闭症患者
自闭症患者 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 06:55

    You need to store the original size of your widget parent window before applying any changes to the layout and restore it when the user switches back to the original.

    Notice that you need to work with the widget parent window size and not the widget parent size.

    in your widget before applying the layout changes:

    minimumWindowSize = this->window().size();
    

    when you finished reorganizing the widget to the compact size

    this->window().resize(minimumWindowSize);
    

提交回复
热议问题