QFormLayout
n行兩列表單,提供了一套insertRow、removeRow、addRow的方法,此類默認第一列爲QLabel,支持第一列只提供字符串而不提供QLabel對象
表單換行策略
setRowWrapPolicy(RowWrapPolicy policy)
Constant | Value | Description |
---|---|---|
QFormLayout::DontWrapRows |
0 |
一直在一行Fields are always laid out next to their label. This is the default policy for all styles except Qt Extended styles. |
QFormLayout::WrapLongRows |
1 |
自適應,如果空間不夠則兩行Labels are given enough horizontal space to fit the widest label, and the rest of the space is given to the fields. If the minimum size of a field pair is wider than the available space, the field is wrapped to the next line. This is the default policy for Qt Extended styles. |
QFormLayout::WrapAllRows |
2 |
一直兩行Fields are always laid out below their label. |
setWidget(int row, ItemRole role, QWidget *widget)
不使用addrow一類的整行添加,也可以逐個添加,使用此函數需要設置ItemRole
Constant | Value | Description |
---|---|---|
QFormLayout::LabelRole |
0 |
標籤列A label widget. |
QFormLayout::FieldRole |
1 |
輸入框列A field widget. |
QFormLayout::SpanningRole |
2 |
單控件佔用整行A widget that spans label and field columns. |
| 版權聲明: 本站文章採用 CC 4.0 BY-SA 協議 進行許可,轉載請附上原文出處鏈接和本聲明。
| 本文鏈接: Cologic Blog - QLayout窗口布局 - https://www.coologic.cn/2017/12/690/