Python QT開發(七)pyside2 QFormLayout的幾個重要屬性

QFormLayout

n行兩列表單,提供了一套insertRowremoveRowaddRow的方法,此類默認第一列爲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/ 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章