1 Star 0 Fork 82

鲤鱼旗的梦想小站 / Landlords

forked from ibc-dabing / Landlords 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
countdown.cpp 1.12 KB
一键复制 编辑 原始数据 按行查看 历史
kevin 提交于 2021-12-07 23:24 . add file
#include "countdown.h"
#include <QPainter>
CountDown::CountDown(QWidget *parent) : QWidget(parent)
{
setFixedSize(70, 70);
m_timer = new QTimer(this);
connect(m_timer, &QTimer::timeout, this, [=]()
{
m_count--;
if(m_count < 10 && m_count > 0)
{
m_clock.load(":/images/clock.png");
m_number = QPixmap(":/images/number.png").copy(m_count*(30+10), 0, 30, 42).scaled(20, 30);
if(m_count == 5)
{
emit notMuchTime();
}
}
else if(m_count <= 0)
{
m_clock = QPixmap();
m_number = QPixmap();
m_timer->stop();
emit timeout();
}
update();
});
}
void CountDown::showCountDown()
{
m_count = 15;
m_timer->start(1000);
}
void CountDown::stopCountDown()
{
m_timer->stop();
m_clock = QPixmap();
m_number = QPixmap();
update();
}
void CountDown::paintEvent(QPaintEvent *ev)
{
Q_UNUSED(ev)
QPainter p(this);
p.drawPixmap(rect(), m_clock);
p.drawPixmap(24, 24, m_number.width(),m_number.height(), m_number);
}
1
https://gitee.com/liyuqi_dreamstation/landlords.git
git@gitee.com:liyuqi_dreamstation/landlords.git
liyuqi_dreamstation
landlords
Landlords
master

搜索帮助

53164aa7 5694891 3bd8fe86 5694891