<dialog.h>
#ifndef DIALOG_H
#define DIALOG_H
#include<Qlabel>
#include<QLineEdit>
#include<QPushButton>
#include <QDialog>
class Dialog : public QDialog
{
Q_OBJECT
public:
Dialog(QWidget *parent = 0);
~Dialog();
protected:
QLabel *label1,*label2,*datalabel;
QLineEdit *lineEdit1,*lineEdit2;
QPushButton *button1,*button2,*button3;
public slots:
void showTime();
void clear();
private:
QTimer *m_timer;
void InitTimer();
};
#endif // DIALOG_H
<dialog.cpp>
#include "dialog.h"
#include <QDebug>
#include<QGridLayout>
#include<QDateTime>
#include<QTimer>
Dialog::Dialog(QWidget *parent)
: QDialog(parent)
{
label1=new QLabel(this);
label1->setText(tr("用户名:"));
label2=new QLabel(this);
label2->setText(tr("密码:"));
datalabel=new QLabel(this);
lineEdit1=new QLineEdit(this);
lineEdit1->setPlaceholderText("4位字母用户名");
lineEdit2=new QLineEdit(th