gpt4 book ai didi

c++ - 在 Qt 中,在使用 hide() 或 setVisible(false) 时,如何阻止子网格布局尝试将所有内容居中?

转载 作者:搜寻专家 更新时间:2023-10-31 01:34:53 24 4
gpt4 key购买 nike

我真正想做的是告诉它在调用 setVisible(true) 或 setVisible(false) 时不要移动东西。我该怎么做?

最佳答案

使用QSizePolicy::setRetainSizeWhenHidden :

void QSizePolicy::setRetainSizeWhenHidden(bool retainSize)

Sets whether a layout should retain the widget's size when it is hidden. If retainSize is true, the layout will not be changed by hiding the widget.

换句话说:

QSizePolicy p = widget->sizePolicy();
p.setRetainSizeWhenHidden(true);
widget->setSizePolicy(p);

关于c++ - 在 Qt 中,在使用 hide() 或 setVisible(false) 时,如何阻止子网格布局尝试将所有内容居中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38424238/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com