#include "widget.h"
#include "ui_widget.h"
const QString INITLCDNUMBER = "88:88:88:88";
static QString g_numStr = "00:00:00:0";
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
m_hour = 0;
m_minute = 0;
m_seconds = 0;
upWid = new QLCDNumber(this);
downWid = new QLCDNumber(this);
//downWid->setStyleSheet("background-color: yellow");
downWid->setAttribute(Qt::WA_TranslucentBackground, true);
downWid->setMode(QLCDNumber::Dec);
downWid->setFrameStyle(QFrame::Panel | QFrame::Raised);
downWid->setDigitCount(11);
downWid->setSegmentStyle(QLCDNumber::Filled);
downWid->setBackgroundRole(QPalette::Background);
QPalette lcdp = downWid->palette();
lcdp.setColor(QPalette::Foreground,QColor(qRgb(51,255,51)));
downWid->setPalette(lcdp);
downWid->display("00:00:00:00");
//upWid->setStyleSheet("background-color: red");
upWid->setAttribute(Qt::WA_TranslucentBackground, true);
upWid->setMode(QLCDNumber::Dec);
upWid->setFrameStyle(QFrame::Panel | QFrame::Raised);
upWid->setBackgroundRole(QPalette::Background);
upWid->setDigitCount(11);
upWid->setSegmentStyle(QLCDNumber::Filled);
QPalette lcdp1 = upWid->palette();
lcdp1.setColor(QPalette::Foreground,QColor(qRgb(51,102,51)));
upWid->setPalette(lcdp1);//QColor(30,96,53)
upWid->display(INITLCDNUMBER);
upWid->show();
downWid->show();
upWid->setGeometry(0,0,this->width(),this->height());
downWid->setGeometry(0,0,this->width(),this->height());
time =new QTimer;
time->setTimerType(Qt::TimerType::PreciseTimer);
connect(time,SIGNAL(timeout()),this,SLOT(ContinueLCDTime()));
time->start(1000);
update();
}
Widget::~Widget()
{
delete ui;
}
void Widget::updateLayout()
{
upWid->setGeometry(0,0,this->width(),this->height());
downWid->setGeometry(0,0,this->width(),this->height());
}
void Widget::paintEvent(QPaintEvent *event)
{
updateLayout();
}
void Widget::slots_timeOut()
{
static int id = 0;
if(id > 100)
id = 0;
else
{
id++;
downWid->display(id);
}
}
void Widget::ContinueLCDTime()
{
m_seconds++;
if (m_seconds == 60) {
m_minute++;
m_seconds = 0;
}
if (m_minute == 60) {
m_hour++;
m_minute = 0;
}
if (m_hour == 24) {
m_hour = 0;
}
QString seconds;
QString minutes;
QString hours;
if (m_seconds < 10)
seconds = "0" + QString::number(m_seconds);
else
seconds = QString::number(m_seconds);
if (m_minute < 10)
minutes = "0" + QString::number(m_minute);
else
minutes = QString::number(m_minute);
if (m_hour < 10)
hours = "0" + QString::number(m_hour);
else
hours = QString::number(m_hour);
QString lcdText;
lcdText = QString("%1:%2:%3:%4").arg("00").arg(hours).arg(minutes).arg(seconds);
downWid->display(lcdText);
}
liuzhezhe111
- 粉丝: 41
- 资源: 7
最新资源
- springboot城市地名地址信息管理系统(源码+sql).zip
- Springboot+vue疫情信息管理系统(源码).zip
- springboot+mysql网上家具商城(源码+sql+论文报告).zip
- python毕业设计基于tensorflow的人脸识别系统设计与实现源码+数据集+模型
- 机械设计天窗装配线PA10 OFFLINE组装工位(sw16可编辑+工程图)项目全套技术资料.zip
- springboot+vue+redis前后端分离网上商城项目003(源码+sql).zip
- PHP入门教程及参考手册chm最新版本
- springboot+redis水果超市商城系统(源码+sql+论文报告).zip
- springboot 学生成绩请假信息管理系统002(源码+sql).zip
- springboot 小区车位管理系统(源码+sql).zip
- springboot+layui仓库管理系统(源码+sql).zip
- springboot 酒庄内部管理系统(源码+sql+论文).zip
- springboot layui 装修验收管理系统(源码+sql).zip
- springboot SSM 宠物医院管理系统(源码+论文).zip
- SpringBoot OA办公权限管理系统(源码+sql).zip
- JavaSpringboot学生教务管理系统(源码+sql+文档).zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈