How to make a Qt widget invisible without changing the position of the other Qt widgets?

前端 未结 10 2366
醉梦人生
醉梦人生 2020-12-01 10:09

I\'ve got a window full of QPushButtons and QLabels and various other fun QWidgets, all layed out dynamically using various QLayout objects... and what I\'d lik

10条回答
  •  -上瘾入骨i
    2020-12-01 10:44

    I had a similar problem and I ended up putting a spacer next to my control with a size of 0 in the dimension I cared about and an Expanding sizeType. Then I marked the control itself with an Expanding sizeType and set its stretch to 1. That way, when it's visible it takes priority over the spacer, but when it's invisible the spacer expands to fill the space normally occupied by the control.

提交回复
热议问题