一、问题
解决方案:
(1)绝对定位组件的坐标和大小
(2)嵌套QBoxLayout
(3)创建3*2的QGridLayout
二、布局管理器
QformLayout布局管理器
以表单(Form)的方式管理界面组件
表单布局中的标签和组件是相互对应的关系
QFormLayout的用法概要
表单布局支持嵌套,其他布局管理器可以作为子布局被其管理。
三、编程实验 24-2.pro QformLayout的实现实例
#include "Widget.h"
#include <QLineEdit>
#include <QFormLayout>
Widget::Widget(QWidget *parent) : QWidget(parent, Qt::WindowCloseButtonHint)
{
QLineEdit* nameEdit = new QLineEdit();
QLineEdit* mailEdit = new QLineEdit();
QLineEdit* addrEdit = new QLineEdit();
QFormLayout* layout = new QFormLayout();
layout->addRow("Name:", nameEdit);
layout->addRow("Email:", mailEdit);
layout->addRow("Address:", addrEdit);
layout->setRowWrapPolicy(QFormLayout::WrapLongRows);
layout->setLabelAlignment(Qt::AlignRight);
layout->setSpacing(10);
setLayout(layout);
setWindowTitle("FTP");
}
Widget::~Widget()
{
}
QFormLayout的样式函数
void setRowWrapPolicy(RowWrapPolicy,policy)
void setLabeLAlignment(Qt::Alignment alignment)
四、小结
QFormLayout以表单的方式管理界面组件
QFormLayout的样式设置简洁明了
QFormLayout支持的布局管理器相互嵌套
QFormLayout是嵌入式产品中最常用的布局方式
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。