#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();
}
}
登录界面