如何在 show() 之前预览布局中小部件的大小? [英] How to preview sizes of widgets in layout before a show()?

查看:28
本文介绍了如何在 show() 之前预览布局中小部件的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在应用布局规则后之前预览窗口中小部件的大小,show()实际上是show()小部件窗口?在初始 show() 命令之前,似乎所有尺寸都是 100x30.我该如何解决?

How do I preview what the size of widgets in a window will be after the layout rules are applied, before I actually show() the widget window? It seems all sizes are 100x30 before that initial show() command. How do I go around that?

推荐答案

invalidate() 对我有用.

请注意,如果您执行以下操作,它将按照此处的要求工作(至少在我的代码中似乎没问题):

Notice that if you do the following it would work as asked here (at least it seems to be fine in my code):

widget->show();
widget->layout()->invalidate();
widget->hide();

这不会在屏幕上显示小部件,因为在 hide() 发生之前您不会将控制权交还给队列.在两者之间,invalidate() 计算正确的位置.

This doesn't show the widget on the screen since you don't relinquish control back to the queue until the hide() happens. In between, the invalidate() computes the correct positions.

这篇关于如何在 show() 之前预览布局中小部件的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆