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/ 

原创文章 17 获赞 1 访问量 1498

猜你喜欢

转载自blog.csdn.net/mankaichuang/article/details/105999024