码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • 王杰qtday4


    widget.h

    1. #ifndef WIDGET_H
    2. #define WIDGET_H
    3. #include
    4. #include
    5. #include
    6. #include
    7. #include
    8. #include
    9. #include
    10. QT_BEGIN_NAMESPACE
    11. namespace Ui { class Widget; }
    12. QT_END_NAMESPACE
    13. class Widget : public QWidget
    14. {
    15. Q_OBJECT
    16. public:
    17. Widget(QWidget *parent = nullptr);
    18. ~Widget();
    19. void timerEvent(QTimerEvent *e);
    20. private slots:
    21. void on_startbtn_clicked();
    22. void on_stopbtn_clicked();
    23. private:
    24. Ui::Widget *ui;
    25. int tid;
    26. QTextToSpeech *speecher;
    27. QString s;
    28. };
    29. #endif // WIDGET_H

    widget.cpp

    1. #include "widget.h"
    2. #include "ui_widget.h"
    3. Widget::Widget(QWidget *parent)
    4. : QWidget(parent)
    5. , ui(new Ui::Widget)
    6. {
    7. ui->setupUi(this);
    8. ui->lineEdit->setPlaceholderText("设置闹钟");
    9. speecher = new QTextToSpeech(this);
    10. }
    11. Widget::~Widget()
    12. {
    13. delete ui;
    14. }
    15. void Widget::timerEvent(QTimerEvent *e)
    16. {
    17. if(e->timerId() == tid)
    18. {
    19. //获取时间
    20. QTime sys_time = QTime::currentTime();
    21. //转换成字符串
    22. s = sys_time.toString("hh::mm::ss");
    23. //放入标签
    24. ui->timelab->setText(s);
    25. ui->timelab->setAlignment(Qt::AlignCenter);
    26. if(ui->lineEdit->text() == s)
    27. {
    28. int i = 0;
    29. ui->textlab->setText("坤坤喊你起床啦,别睡了爱坤");
    30. while(i<20)
    31. {
    32. speecher->say("坤坤喊你起床啦,别睡了爱坤");
    33. i++;
    34. }
    35. }
    36. }
    37. }
    38. void Widget::on_startbtn_clicked()
    39. {
    40. if(ui->startbtn->text() == "启动")
    41. {
    42. tid = startTimer(1000);
    43. ui->startbtn->setText("关闭");
    44. }
    45. else if(ui->startbtn->text() == "关闭")
    46. {
    47. killTimer(tid);
    48. ui->startbtn->setText("启动");
    49. }
    50. }
    51. void Widget::on_stopbtn_clicked()
    52. {
    53. speecher->stop();
    54. }

  • 相关阅读:
    2251: 【区赛】【海曙2017】波波爱看NBA
    模拟量偏差报警功能块(SCL代码)
    ERP 实施,甲方公司前期应该准备什么?
    短视频平台如何保证内容安全问题?
    java面试题,各大企业常见的java笔试题及答案(精华)
    java计算机毕业设计ssm建设路小学读背兴趣任务管理系统
    第四节——Vue属性绑定
    SpringBoot定时任务(@EnableScheduling注解)
    【List篇】使用Arrays.asList生成的List集合,操作add方法报错
    PYTHON用[有向图-邻接表]来描述社交网络中的[关注关系]
  • 原文地址:https://blog.csdn.net/wwjj26/article/details/133953430
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号