1
2
#include "mywidget.h"
#include "ui_mywidget.h"
myWidget::myWidget(QWidget *parent)
: QWidget(parent)
, ui(new Ui::myWidget)
{
ui->setupUi(this);
ui->label1->setAlignment(Qt::AlignCenter);
speecher=new QTextToSpeech(this);
startTimer(1000);
emit settime();
}
myWidget::~myWidget()
{
delete ui;
}
void myWidget::timerEvent(QTimerEvent *e)
{
emit settime();
if(num==ui->label1->text())
{
for(int i=0;i<5;i++)
{
speecher->say("你是小黑子");
}
QMovie *mv=new QMovie("C:\\Users\\18065\\Desktop\\pictrue\\kun.gif");
mv->setParent(this);
ui->label3->setMovie(mv);
mv->start();
ui->label3->setScaledContents(true);
}
}
void myWidget::settime()
{
QTime time=QTime::currentTime();
QString t=time.toString("hh:mm:ss");
ui->label1->setText(t);
}