Qt 中的布局管理器
以下引用来自此链接: http://doc.qt.io/qt -5/qwidget.html#setLayout
如果已经有布局管理器 安装在这个小部件上,QWidget 不会让你安装另一个。你 必须先删除现有的布局 管理器(由layout()返回)之前 您可以使用新的调用 setLayout() 布局。
问题 1:当您说“布局管理器安装在此小部件上”时,这是什么意思?
问题 2:此链接:http ://doc.qt.io/qt-5/layout.html 显示布局有多种形式,例如:水平布局、垂直布局、表单布局。网格布局可以单独用于以其他三种布局支持的形式排列小部件。其他三种布局有什么特殊用途吗?
The following quote is from this link: http://doc.qt.io/qt-5/qwidget.html#setLayout
If there already is a layout manager
installed on this widget, QWidget
won't let you install another. You
must first delete the existing layout
manager (returned by layout()) before
you can call setLayout() with the new
layout.
Question 1: What does it mean when you say is "layout manager is installed on this widget"?
Question 2: This link: http://doc.qt.io/qt-5/layout.html shows that there are various forms of layouts like: Horizontal, Vertical, Form Layouts. Grid layout can alone be used to arrange the widgets in the forms supported by other three layouts. Is there any special use of the other three layouts?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您使用
setLayout
将布局设置为小部件的布局时,布局就会“安装”在小部件中。这就是全部意思。至于使用什么布局:使用可以完成您想要的工作的最简单的布局。使用嵌套(您可以将一个布局添加到另一个布局)来进行更复杂的设计。网格不一定是最容易使用的 - 如果使用单个网格作为布局,您很快就会发现自己对需要跨越多行/列的小部件、间距困难等感到头痛。
A layout is "installed" in a widget when you set it as the widget's layout with
setLayout
. That's all it means.As for what layouts to use: use the simplest layout that does the job you want. Use nesting (you can add a layout to another layout) to make more complex designs. A grid is not necessarily the easiest to use - you'll soon find yourself with headaches about widgets needing to span multiple rows/columns, spacing difficulties etc... if use a single grid as your layout.