content(堆栈窗体编写)
堆栈布局
#ifndef CONTENT_H
#define CONTENT_H
#include <QFrame>
#include <QDialog>
#include <QStackedWidget>
#include <QPushButton>
#include "baseinfo.h"
#include "contact.h"
#include "detail.h"
class content : public QFrame
{
Q_OBJECT
public:
content(QWidget *parent = 0);
~content();
QStackedWidget *stack;
QPushButton *AmendBtn;
QPushButton *CloseBtn;
BaseInfo *baseinfo;
Contact *contact;
Detail *detail;
};
#endif
#include "content.h"
#include <QHBoxLayout>
content::content(QWidget *parent) : QFrame(parent)
{
stack =new QStackedWidget(this);
stack->setFrameStyle(QFrame::Panel|QFrame::Raised);
baseinfo=new BaseInfo();
contact=new Contact();
detail=new Detail();
stack->addWidget(baseinfo);
stack->addWidget(contact);
stack->addWidget(detail);
AmendBtn=new QPushButton(tr("修改"));
CloseBtn=new QPushButton(tr("关闭"));
QHBoxLayout *BtnLayout=new QHBoxLayout;
BtnLayout->addStretch(1);
BtnLayout->addWidget(AmendBtn);
BtnLayout->addWidget(CloseBtn);
QVBoxLayout *RightLayout=new QVBoxLayout(this);
RightLayout->setMargin(10);
RightLayout->setSpacing(6);
RightLayout->addWidget(stack);
RightLayout->addLayout(BtnLayout);
}
content::~content()
{
}
BASEINFO(基本信息界面编写)
#ifndef BASEINFO_H
#define BASEINFO_H
#include <QWidget>
#include <QLabel>
#include <QLineEdit>
#include <QComboBox>
#include <QTextEdit>
#include <QGridLayout>
#include <QPushButton>
class BaseInfo : public QWidget
{
Q_OBJECT
public:
explicit BaseInfo(QWidget *parent = nullptr);
signals:
public slots:
private:
QLabel *UserNamelabel;
QLabel *Namelabel;
QLabel *Sexlabel;
QLabel *Departmentlabel;
QLabel *Agelabel;
QLabel *Otherlabel;
QLineEdit *UserNameLineEdit;
QLineEdit *NameLineEdit;
QComboBox *SexComboBox;