QT登陆界面,运用正则表达式,时间显示和定时器

该博客介绍了如何在QT中利用正则表达式QRegExp进行登录界面的输入验证,同时展示了如何实现显示当前实时时间的功能,通过QDateTime转换日期时间并设置格式。此外,还讲解了使用QTimer创建定时器,每2秒更新时间显示的方法。
<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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值