使用 Qt-Designer 自动扩展布局

发布于 2024-09-14 16:24:09 字数 169 浏览 11 评论 0原文

我正在使用 Qt 设计器。

我想创建一个 QVBoxLayout 它将自动扩展以填充整个窗口。

QVBoxLayout 的布局保持固定。

如何通过设计器使QVBoxLayout展开并填充整个窗口?

I'm using the Qt Designer.

I want to create a QVBoxLayout which will automatically expand to fill the whole window.

The layout of the QVBoxLayout remains fixed.

How can I cause the QVBoxLayout to expand and fill the entire window through the designer?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

谈情不如逗狗 2024-09-21 16:24:09

在 Qt Designer 中创建 QVBoxLayout 后,右键单击小部件/对话框/窗口的背景(不是 QVBoxLayout,而是父小部件)并选择 布局 ->从上下文菜单的底部在网格中布局QVBoxLayout 现在应该拉伸以适合窗口,并在调整整个窗口大小时自动调整大小。

After creating your QVBoxLayout in Qt Designer, right-click on the background of your widget/dialog/window (not the QVBoxLayout, but the parent widget) and select Lay Out -> Lay Out in a Grid from the bottom of the context-menu. The QVBoxLayout should now stretch to fit the window and will resize automatically when the entire window is resized.

昨迟人 2024-09-21 16:24:09

根据文档,需要有一个顶级布局集。

顶级布局对于确保您的窗口小部件在调整窗口大小时能够正确调整大小是必要的。要检查您是否已设置顶级布局,请预览小部件并尝试通过拖动大小夹点来调整窗口大小。

您可以通过清除选择并右键单击表单本身并选择上下文菜单中可用的布局之一来设置之一。

Qt 布局

According to the documentation, there needs to be a top level layout set.

A top level layout is necessary to ensure that your widgets will resize correctly when its window is resized. To check if you have set a top level layout, preview your widget and attempt to resize the window by dragging the size grip.

You can set one by clearing the selection and right clicking on the form itself and choosing one of the layouts available in the context menu.

Qt layouts

回眸一笑 2024-09-21 16:24:09

我试图找到一个“适合屏幕”的属性,但没有这样的属性。

但是将小部件的“maximumSize”设置为“某个大数字”(例如 2000 x 2000 )将自动使小部件适合父小部件空间。

I've tried to find a "fit to screen" property but there is no such.

But setting widget's "maximumSize" to a "some big number" ( like 2000 x 2000 ) will automatically fit the widget to the parent widget space.

请止步禁区 2024-09-21 16:24:09

添加至少包含一个小部件的布局后,选择您的窗口并单击 QtDesigner 的“更新”按钮。界面将以最优化的尺寸调整,您的布局将适合整个窗口。然后当调整窗口大小时,布局也会以同样的方式调整大小。

Once you have add your layout with at least one widget in it, select your window and click the "Update" button of QtDesigner. The interface will be resized at the most optimized size and your layout will fit the whole window. Then when resizing the window, the layout will be resized in the same way.

青巷忧颜 2024-09-21 16:24:09

设置horizo​​ntalPolicy &将控件/小部件的 VerticalPolicy 设置为“首选”

Set the horizontalPolicy & VerticalPolicy for the controls/widgets to "Preferred".

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文