QTabWidget 拒绝自动调整大小
我试图在 qtcreator 中采用以下布局:
QWidget
QSplitter
QStackedWidget
...
QStackedWidget
QWidget (page)
QTabWidget
每个具有 sizePolicy
的控件都设置为 Expanding
。尽管如此,选项卡小部件和我放在该页面小部件上的其他任何东西都不会自动调整大小。
我是 Qt 新手,所以如果这是一个明显的修复,请原谅我。谢谢。
I'm attempting to have the following layout in qtcreator:
QWidget
QSplitter
QStackedWidget
...
QStackedWidget
QWidget (page)
QTabWidget
Every single control that has a sizePolicy
is set to Expanding
. Despite this, neither the tab widget nor anything else I drop on that page widget gets autosized.
I'm new to Qt, so forgive me if this is an obvious fix. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是重复的吗
如何制作 Qt 小部件随着窗口大小而增长? ?
我认为这是重复的,因为如果你的小部件树中的每个项目都有一个布局,我对 Qt 4.7 的测试给出了以下输出,右侧是我的对象检查器。
我只是放入了小部件并对其进行了布局,我没有更改任何大小来扩展,因为这绝对是不必要的!
左侧是正在运行的 exe,右侧是创建者屏幕截图。
这是我的用户界面:
Is this a duplicate of
How to make a Qt Widget grow with the window size? ?
I think it is a duplicate, cause if every item in your tree of widgets has a layout, my test on Qt 4.7 gave the following output, on the right side is my object inspector.
I did just put in the widgets and layouted them, i did not change any size things to expanding, as this is absolutely unnecessary!
On the left is the running exe, on the right is the Creator screenshot.
And here is my UI:
您需要以下层次结构(请注意
QLayout
):因此代码如下所示:
You need the following hierarchy note the
QLayout
):So the code is something like this:
我在设计器中创建了一个新的顶级窗口(QWidget),并将两个堆叠的小部件放在上面,按住 Ctrl 键单击它们以选择它们,然后右键单击它们并选择“在分割器中水平布局”。然后我右键单击顶层 QWidget 并选择“布局在网格中”。此后,两个堆叠的小部件将扩展以填充可用空间,并且它们会随着顶层窗口的大小而适当地增长和收缩。也许您只需要为顶级小部件设置布局?
I created a new top level window (QWidget) in designer and drop two stacked widgets on it, ctrl-click both of them to select them and then right-clicked them and selected "Layout Horizontally in Splitter". I then right clicked on the top level QWidget and selected "Layout in a Grid". After this, the two stacked widgets expand to fill the avaialable space and they properly grow and shrink with the top level window. Perhaps you just need to set a layout for the top level widget?