#include "second.h"
#include "ui_second.h"
Second::Second(QWidget *parent) :
QWidget(parent),
ui(new Ui::Second),
speech(new QTextToSpeech(this))
{
ui->setupUi(this);
}
void Second::my_jump()
{
show();
}
void Second::timerEvent(QTimerEvent *e)//重写定时器事件的实现
{
QTime s=QTime::currentTime();
QString t=s.toString("hh::mm::ss");
if(e->timerId()==id)
{
// QTime s=QTime::currentTime();
// QString t=s.toString("hh::mm::ss");
ui->label->setText(t);
ui->label->setAlignment(Qt::AlignCenter);
}else if(e->timerId()==id1)
{
if(t==ui->lineEdit->text())
{
ui->label_3->setText("你这个年龄段振不到刀,你怎么睡的着的");
speech->say(ui->label_3->text());
//QUrl source(QUrl::fromLocalFile());
}
}
}
Second::~Second()
{
delete ui;
}
void Second::on_pushButton_clicked()
{
if(ui->pushButton->text()=="启动")
{
ui->pushButton->setText("关闭");
}
else{
killTimer(id);
killTimer(id1);
ui->pushButton->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_btn2_clicked()
{
QMessageBox msg(QMessageBox::Question,"问题","您是否确定退出登录?",QMessageBox::Yes|QMessageBox::No,this);
int ret=msg.exec();
if(ret==QMessageBox::Yes)
{
close();
}
else
{
msg.close();
}
}
void Widget::on_btn1_clicked()
{
QString a=ui->lineEdit->text();
QString b=ui->lineEdit_2->text();
if(a=="admin"&&b=="123456")
{
int ret=QMessageBox::information(this,"信息","登录成功",QMessageBox::Ok);
if(ret==QMessageBox::Ok)
{
close();
emit my_signal();
}
}
else{
int ret1=QMessageBox::warning(this,"错误","账号密码不匹配,是否重新登录",QMessageBox::Yes|QMessageBox::No);
if(ret1==QMessageBox::Yes)
{
ui->lineEdit_2->clear();
}
else{
close();
}
}
}
![](https://img-blog.csdnimg.cn/direct/fd33e47ab42147bbb150a4d7a225b717.jpeg)
![](https://img-blog.csdnimg.cn/direct/19dfceac35b54d27a23326916b1fe052.jpeg)
![](https://img-blog.csdnimg.cn/direct/89631bc62c1f4c718523a14a90a1b428.jpeg)
![](https://img-blog.csdnimg.cn/direct/f212a34166ab416cbad8dc4e1cf9a96d.jpeg)