第1步:建立页面工程,项目名称为“Example”,基类为“QDialog”,类名为Contant,取消创建界面复选框的选中状态。
第2步:建立修改用户基本信息类,基类为QWidget
(1)baseinfo.h
#ifndef BASEINFO_H
#define BASEINFO_H
#include <QWidget>
#include<QLabel> //标签
#include<QLineEdit>
#include<QComboBox> //下拉列表框,item,,列表项
#include<QTextEdit> //多行文本框控件
#include<QGridLayout> //网格布局
#include <QPushButton> //按钮
class BaseInfo : public QWidget
{
Q_OBJECT
public:
explicit BaseInfo(QWidget *parent = nullptr);
signals:
private:
//左侧
QLabel *UsernameLabel; //用户名
QLabel *NameLabel; //姓名
QLabel *SexLabel; //性别
QLabel *DepartmentLabel; //部门
QLabel *AgeLabel; //年龄
QLabel *OtherLabel; //其它
QLineEdit *UserNameLineEdit; //用户名编辑框
QLineEdit *NameLineEdit; //姓名编辑框
QComboBox *SexComboBox; //性别组合框
QTextEdit *DepartmentTextEdit; //部门文本框
QLineEdit *AgeLineEdit; //年龄编辑框
QGridLayout *LeftLayout; //网格布局
//右侧
QLabel *Headlabel; //左上角
QLabel *HeadIconLabel;
QPushButton *UpdateHeadBtn; //更新按钮
QHBoxLayout *TopRightLayout; //水平布局
QLabel *IntroductionLabel; //个人说明
QTextEdit *IntroductionTextEdit; //个人说明文本框
QVBoxLayout *RightLayout; //垂直布局
};
#endif // BASEINFO_H
(2)baseinfo.cpp
#include "baseinfo.h"
BaseInfo::BaseInfo(Q