开发者

auto adjustSize()

my widget has children widgets which can appear and disappear sometimes. Now after hiding one of child I call adjustSize() to resize the main widget to possible minimum.

How to automatically call adjustSize() when showing/hiding children i开发者_StackOverflow社区n a layout? I tried setting sizePolicy to QSizePolicy::Minimum but this doesn't help...


When you call

QWidget::setVisibility(true/false)
QWidget::hide()
QWidget::show()

it generates a showEvent or a hideEvent see doc here. So, what you could do is to install an eventFilter on your widget to check when the showEvent is called and then call adjustSize when it is required.

See doc here for details about the event filter.

Hope that helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜