当前位置: 首页 > news >正文

郓城菏泽网站建设做物流网站的公司

郓城菏泽网站建设,做物流网站的公司,3万网站建设费会计分录,智加设计设置一个闹钟,左侧窗口显示当前时间,右侧设置时间,以及控制闹钟的开关,下方显示闹钟响时的提示语。当按启动按钮时,设置时间与闹钟提示语均不可再改变。当点击停止时,关闭闹钟并重新启用设置时间与闹钟提示…

        设置一个闹钟,左侧窗口显示当前时间,右侧设置时间,以及控制闹钟的开关,下方显示闹钟响时的提示语。当按启动按钮时,设置时间与闹钟提示语均不可再改变。当点击停止时,关闭闹钟并重新启用设置时间与闹钟提示语。

闹钟窗口展示:

工程管理文件:

QT       += core gui texttospeechgreaterThan(QT_MAJOR_VERSION, 4): QT += widgetsCONFIG += c++11# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS# You can also make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0SOURCES += \main.cpp \widget.cppHEADERS += \widget.hFORMS += \widget.ui# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += targetRESOURCES += \picture.qrc

头文件:

#ifndef WIDGET_H
#define WIDGET_H#include <QWidget>
#include <QDebug>
#include <QLabel>   //标签
#include <QTextEdit>    //文本编辑器
#include <QLineEdit>    //行编辑器
#include <QPushButton>  //按钮#include <QTimerEvent>  //事件处理函数
#include <QDateTime>
#include <QtTextToSpeech>    //播报员
#include <QPaintEvent>
#include <QPainter>QT_BEGIN_NAMESPACE
namespace Ui { class Widget; }
QT_END_NAMESPACEclass Widget : public QWidget
{Q_OBJECTpublic slots://定义启动按钮的槽函数void on_btnStart_clicked();//定义停止按钮的槽函数void on_btnStop_clicked();public:Widget(QWidget *parent = nullptr);~Widget();//重写定时器事件处理函数void timerEvent(QTimerEvent *event) override;void paintEvent(QPaintEvent *event) override;void mouseMoveEvent(QMouseEvent *event) override;void mousePressEvent(QMouseEvent *event) override;private:Ui::Widget *ui;QLabel *lab_time;QPushButton *btn_start;QPushButton *btn_stop;QLineEdit *line_setTime;QTextEdit *text_show;int time_id;    //基于事件处理函数QString oclock;   //设置闹钟QTextToSpeech *speak;   //设置播报员QPoint drap;
};
#endif // WIDGET_H

主函数:

#include "widget.h"#include <QApplication>int main(int argc, char *argv[])
{QApplication a(argc, argv);Widget w; w.show();return a.exec();
}

主要功能函数:

#include "widget.h"
#include "ui_widget.h"Widget::Widget(QWidget *parent): QWidget(parent), ui(new Ui::Widget)
{ui->setupUi(this);//实例化一个播报员speak = new QTextToSpeech(this);time_id = this->startTimer(1000);//纯净窗口this->setWindowFlag(Qt::FramelessWindowHint);//固定窗口尺寸this->setFixedSize(540,410);//显示当前时间lab_time = new QLabel(this);lab_time->setAlignment(Qt::AlignCenter);lab_time->setStyleSheet("border:2px solid rgb(0, 170, 255);font:16pt;border-radius:10px;color:white");lab_time->setGeometry(20,20,300,120);//设置text窗口text_show = new QTextEdit(this);text_show->setPlaceholderText("请输入闹钟提示语");text_show->setAlignment(Qt::AlignCenter);text_show->setStyleSheet("border:2px solid rgb(0, 170, 255);border-radius:5px;font:20pt;background-color:transparent;color:white");text_show->setGeometry(20,150,500,250);//显示设置的时间line_setTime = new QLineEdit(this);line_setTime->setPlaceholderText("请设置时间");line_setTime->setAlignment(Qt::AlignCenter);line_setTime->setStyleSheet("border:2px solid rgb(0, 170, 255);font:16pt;border-radius:10px;background-color:transparent;color:white");line_setTime->setGeometry(350,20,170,60);//启动按钮btn_start = new QPushButton(this);btn_start->setText("启动");btn_start->setStyleSheet("border:2px solid rgb(0, 170, 255);border-radius:10px;font:14pt;color:white");btn_start->setGeometry(350,90,80,50);//停止按钮btn_stop = new QPushButton(this);btn_stop->setText("停止");btn_stop->setStyleSheet("border:2px solid rgb(0, 170, 255);border-radius:10px;font:14pt;color:white");btn_stop->setGeometry(440,90,80,50);//启动按钮connect(btn_start, &QPushButton::clicked, this, &Widget::on_btnStart_clicked);connect(btn_stop, &QPushButton::clicked, this, &Widget::on_btnStop_clicked);}Widget::~Widget()
{delete ui;
}void Widget::on_btnStart_clicked()
{oclock = line_setTime->text();line_setTime->setEnabled(false);text_show->setEnabled(false);btn_start->setText("已启动");
}void Widget::on_btnStop_clicked()
{line_setTime->setEnabled(true);text_show->setEnabled(true);speak->stop();btn_start->setText("启动");
}
void Widget::timerEvent(QTimerEvent *event)
{if(event->timerId() == time_id){QDateTime time = QDateTime::currentDateTime();lab_time->setText(time.toString("yyyy-MM-dd hh:mm:ss"));if(oclock == time.toString("hh:mm:ss")){speak->say(text_show->toPlainText());}}
}void Widget::paintEvent(QPaintEvent * event)
{QPainter painter(this);painter.drawPixmap(rect(),QPixmap(":/picture/back.jpg"),QRect());
}void Widget::mousePressEvent(QMouseEvent *event)
{drap = event->globalPos() - this->pos();//右键关闭窗口if(event->button() == Qt::RightButton){this->close();}
}void Widget::mouseMoveEvent(QMouseEvent *event)
{this->move(event->globalPos() - drap);
}
http://www.yayakq.cn/news/822081/

相关文章:

  • 江苏省国家示范校建设专题网站seo对各类网站的作用
  • 做网站游戏的网站有哪些html5开发微网站
  • 网站建设属于什么领域小伙做网色网站
  • 深圳网站建设公司小江江苏省建筑信息平台
  • 免费网站建设怎样建设网站只能是公司
  • 晋江网站建设报价帮网贷做网站会判刑吗
  • 无锡网站建设seo网站用什么主机
  • 学网站开发难吗寺庙做网站
  • 网站开发需要哪些软件电销外呼系统多少钱一个月
  • 临沂网站建设方案服务wordpress+云播插件
  • 福建网站设计制作网络营销服务平台
  • 加强财政门户网站建设工作深圳网站建设公
  • 网站建设公司招聘面试他达拉非片
  • 网站开发有哪些方式东莞网页制作
  • 做网站页面的框架淘宝网站建设论文
  • 八年级信息技术怎么制作网站网络营销和电子商务的区别和联系
  • 东山网站制作建设通网
  • 网站制作毕业设计论文北京建网
  • 网站开发语言开发企业网站建设要多
  • 如何做淘宝优惠卷网站自助云商城
  • 手机网站做分享到朋友圈做搜索的网站有哪些
  • 建设一个展示商品的网站asp网站后台验证码错误
  • 网站工程师培训手机的网站建设目标是什么意思
  • c语言开发网站后端网站如何更换域名
  • 总部在深圳的互联网公司做网站优化的关键词怎么设置
  • 班级网站建设感想上海建设教育网站
  • 教育培训网站源码开源零代码开发平台
  • 建设房屋出租网站三网合一网站建设报价
  • 深圳建模板网站品牌型网站建设哪家
  • 安丘网站建设制作wordpress 5.0