QT += core gui texttospeech
******************************************
namespace Ui { class Widget; }
class Widget : public QWidget
Widget(QWidget *parent = nullptr);
*********************************************************
Widget::Widget(QWidget *parent)
this->setWindowFlag(Qt::FramelessWindowHint);
//qDebug()<<this->size();
this->resize(QSize(600,400));
// back = new QLabel(this);//设置背景照片
// back->resize(this->size());
// back->setPixmap(QPixmap(":/new/prefix1/C:/Users/30734/Desktop/zq/zq.png"));
// back->setScaledContents(true);
//label->setStyleSheet("background-color:yellow");
edit=new QLineEdit(this);
edit->move(label->x()+label->width()+30,label->y());
//qDebug() <<edit->size();
edit->resize(QSize(150,25));
edit->setAlignment(Qt::AlignCenter);
edit->setStyleSheet("background: transparent;");
btn1=new QPushButton(this);
btn1->move(edit->x(),label->y()+edit->height()+15);
//qDebug() <<btn1->size();
btn1->resize(QSize(50,30));
connect(btn1,&QPushButton::clicked,this,&Widget::btn1_slot);
btn2=new QPushButton(this);
btn2->move(btn1->x()+btn1->width()+50,btn1->y());
btn2->resize(QSize(50,30));
connect(btn2,&QPushButton::clicked,this,&Widget::btn2_slot);
text=new QTextEdit(this);
text->move(label->x(),label->y()+label->height()+30);
text->resize(QSize(500,215));
text->setText("三更灯火五更鸡\n"
//text->setAlignment(Qt::AlignCenter);
text->setFont(QFont("楷书",18));
text->setStyleSheet("background: transparent;"); // 设置文本编辑器背景为透明
timer = new QTimer(this);
connect(timer,&QTimer::timeout,this,&Widget::timeout_slot);
speecher = new QTextToSpeech(this);
void Widget::timeout_slot()
QTime sys_time = QTime::currentTime();
QString t = sys_time.toString("hh:mm:ss");
this->label->setAlignment(Qt::AlignCenter);
this->label->setFont(QFont("微软雅黑",35));
this->label->setStyleSheet("color: white;");
timer2 = new QTimer(this);//启动后判断闹钟定时器
connect(timer2,&QTimer::timeout,this,&Widget::timeout_slot2);
void Widget::timeout_slot2()
if(edit->text()==label->text())
QString txt=text->toPlainText();