618作业

#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    id = startTimer(1);

}

Widget::~Widget()
{
    delete ui;
}

void Widget::timerEvent(QTimerEvent *e)
{
    if(e->timerId()==id)
    {
        QTime sys_time = QTime::currentTime();
        t1 = sys_time.toString("hh:mm:ss");
        ui->lab1->setText(t1);
    }
    if(e->timerId()==id2)
    {
        QString t2 = ui->le1->text();
        qDebug() << "hh";
        if( t1 == t2)
        {
            qDebug() << "nn";
            //QString t3 = ui->lab3->text();
            QTextToSpeech *sp = new QTextToSpeech;
            for(int i=0;i<5;i++)
            {
                sp->say(ui->lab3->text());
            }
            killTimer(id2);
        }
    }
}

void Widget::on_pb1_clicked()
{
    if(ui->pb1->text() == "启动")
    {

        ui->pb1->setText("取消");
        id2 = startTimer(1);

    }
    else
    {
        killTimer(id2);
        ui->pb1->setText("启动");

    }
}

闹钟

#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    this->setWindowFlag(Qt::FramelessWindowHint);
    this->setAttribute(Qt::WA_TranslucentBackground);
}

Widget::~Widget()
{
    delete ui;



}


void Widget::on_pb_2_clicked()
{
    this->close();
}


void Widget::on_pushButton_clicked()
{
    QString ID = ui->lineEdit->text();
    QString PD = ui->lineEdit_2->text();
    if( ID == "111" && PD == "111" )
    {
        this->close();

        int ret = QMessageBox::information(this,"提示","登陆成功",QMessageBox::Yes);
        if( ret == QMessageBox::Yes )
        {
            emit my_jump();
        }
    }
    else {
        int ret = QMessageBox::warning(this,"登录","登陆失败",QMessageBox::Yes | QMessageBox::No);
        if( ret == QMessageBox::Yes )
        {
            ui->lineEdit->clear();
            ui->lineEdit_2->clear();
        }
        else
        {
            this->close();
        }

    }



}

void Widget::on_pushButton_2_clicked()
{
    int ret = QMessageBox::information(this,"提示","您确认要退出登录吗?",QMessageBox::Yes | QMessageBox::No);
    if(ret == QMessageBox::Yes)
    {
        this->close();
    }
    else
    {
        ui->lineEdit->clear();
        ui->lineEdit_2->clear();
    }
}

登录界面

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值