实现一个简单的垂直布局功能
1.新建一个无ui界面的工程,基类为widget
2.代码实现
widget.cpp
#include
"widget.h"
#include
<QLineEdit>
#include
<QTextEdit>
#include
<QLayout>
Widget
::Widget(QWidget
*parent
)
: QWidget(parent
)
{
QLineEdit
* LineEdit
= new QLineEdit("编辑框");
QTextEdit
* TextEdit
= new QTextEdit();
QVBoxLayout
* Layout
= new QVBoxLayout;
Layout
->addWidget(LineEdit
);
Layout
->addWidget(TextEdit
);
this->setLayout(Layout
);
}
Widget
::~Widget()
{
}
3.效果展示
转载请注明原文地址: https://win8.8miu.com/read-2341.html