还不太完善
#ifndef REGISTER_DLG_H
#define REGISTER_DLG_H
#include <QtGui/QDialog>
#include <QtGui/QVBoxLayout>
#include <QtGui/QHBoxLayout>
#include <QtGui/QGridLayout>
#include <QtGui/QLabel>
#include <QtGui/QLineEdit>
#include <QtGui/QPushButton>
class RegisterDlg : public QDialog
{
Q_OBJECT
public:
RegisterDlg(QWidget *parent = 0);
~RegisterDlg();
public slots:
void checkRegister();
private:
QVBoxLayout* layout;
QLabel* label;
QGridLayout* gridlayout;
QLabel* namelabel;
QLineEdit* nameedit;
QLabel* codelabel;
QLineEdit* codeedit;
QHBoxLayout* hlayout;
QPushButton* confirm;
QPushButton* cancel;
};
#endif
//! ccsdu2004
cxx
#include <QtGui/QMessageBox>
#include "registerdlg.h"
RegisterDlg::RegisterDlg(QWidget *parent)
: QDialog(parent)
{
layout = new QVBoxLayout;
label = new QLabel(tr("Please input register info below"));
layout->addWidget(label);
gridlayout = new QGridLayout;
namelabel = new QLabel(tr("User Name"));
nameedit = new QLineEdit();
codelabel = new QLabel(tr("Register Code"));
codeedit = new QLineEdit();
gridlayout->addWidget(namelabel,0,0);
gridlayout->addWidget(nameedit,0,1);
gridlayout->addWidget(codelabel,1,0);
gridlayout->addWidget(codeedit,1,1);
layout->addLayout(gridlayout);
hlayout = new QHBoxLayout;
confirm = new QPushButton(tr("Confirm"));
cancel = new QPushButton(tr("Cancel"));
hlayout->addWidget(confirm);
hlayout->addWidget(cancel);
layout->addLayout(hlayout);
this->setLayout(layout);
this->setWindowTitle(tr("Register"));
connect(this->cancel,SIGNAL(clicked()),this,SLOT(close()));
connect(this->confirm,SIGNAL(clicked()),this,SLOT(checkRegister()));
}
RegisterDlg::~RegisterDlg()
{
}
void RegisterDlg::checkRegister()
{
}