Layouting::Layout Class
class Layouting::Layout布局构建器类的基类。更多...
| Header: | #include <Layout> |
| Inherits: | Layouting::Object |
| Inherited By: | Layouting::Column, Layouting::Flow, Layouting::Form, Layouting::Grid, and Layouting::Row |
公共函数
| void | addItem(Layouting::Layout::I item) |
| void | addItems(std::initializer_list<Layouting::Layout::I> items) |
| void | addRow(std::initializer_list<Layouting::Layout::I> items) |
| void | align(Qt::Alignment alignment) |
| void | attachTo(QWidget *widget) |
| QWidget * | emerge() const |
| void | flush() |
| void | setNoMargins() |
| void | setNormalMargins() |
| void | span(int cols, int rows) |
详细说明
封装一个由QLayout 派生的对象。实例是短暂存在的:创建、配置,然后调用attachTo()或emerge()。请勿在包含该实例的函数之外存储它们。
子类通过addItem()、addItems()和addRow()累积项目,这些项目会在构建器最终完成时刷入底层的QLayout 中。对于支持行和跨行的布局(如Form、Grid),项目会通过flush()进行分阶段处理并提交到布局中。
另请参阅 Layouting::Widget 、Layouting::Column 、Layouting::Row 、Layouting::Form 以及Layouting::Grid 。
成员函数文档
void Layout::addItem(Layouting::Layout::I item)
将布局项item 添加为子项。
void Layout::addItems(std::initializer_list<Layouting::Layout::I> items)
将布局项items 作为子项添加。
void Layout::addRow(std::initializer_list<Layouting::Layout::I> items)
创建一个包含items 的新行。该行可通过addItem() 或addItems() 进一步添加其他项目。
void Layout::align(Qt::Alignment alignment)
将此布局中最后添加的项目的对齐方式设置为“alignment ”。仅对网格(Grid)和表单(Form)布局有效。
void Layout::attachTo(QWidget *widget)
将构建好的布局附加到提供的QWidget widget 上。
此操作每个 LayoutBuilder 实例仅能执行一次。
QWidget *Layout::emerge() const
最终确定布局,并将其封装在一个新的QWidget 中返回。
当需要将布局作为小部件(例如在QScrollArea 或QStackedWidget 内部)嵌入,且不使用显式的外部Widget构建器时,此方法非常有用。调用方将获得返回的小部件的所有权。
另请参阅 Layout::attachTo()。
void Layout::flush()
将所有累积的待处理项提交到底层的QLayout 中。
对于网格布局,每次调用 flush() 都会跳转到下一行。对于表单布局,每次调用 flush() 都会添加一行标签-字段行(或单个全宽行)。对于盒式布局和流式布局,项目会直接添加,此时 flush() 不会执行任何操作。
在接受初始化列表的构造函数结束时,以及在调用attachTo() 和emerge() 时,会自动调用 flush()。仅当使用addItem() 或addRow() 逐步构建布局时,才应手动调用它。
另请参阅 Layout::attachTo() 和Layout::emerge()。
void Layout::setNoMargins()
将所有四个内容边距均设置为零。
另请参阅 Layout::setNormalMargins() 和Layouting::noMargin 。
void Layout::setNormalMargins()
将所有四个内容边距均设置为 9 像素。
另请参阅 Layout::setNoMargins() 和Layouting::normalMargin 。
void Layout::span(int cols, int rows)
将此布局中最后添加的项的列跨度设置为cols ,行跨度设置为rows 。仅对网格布局有效。
另请参阅 Layouting::Span 和Layouting::SpanAll 。
Copyright © The Qt Company Ltd. and other contributors. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.