加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
loading.cpp 1004 Bytes
一键复制 编辑 原始数据 按行查看 历史
kevin 提交于 2021-12-07 23:24 . add file
#include "gamepanel.h"
#include "loading.h"
#include <QPainter>
#include <QTimer>
Loading::Loading(QWidget *parent) : QWidget(parent)
{
m_bk.load(":/images/loading.png");
setFixedSize(m_bk.size());
setWindowFlags(Qt::FramelessWindowHint | windowFlags());
setAttribute(Qt::WA_TranslucentBackground);
QPixmap pixmap(":/images/progress.png");
QTimer* timer = new QTimer(this);
connect(timer, &QTimer::timeout, this, [=](){
m_progress = pixmap.copy(0, 0, m_dist, pixmap.height());
update();
if(m_dist >= pixmap.width())
{
timer->stop();
timer->deleteLater();
GamePanel* panel = new GamePanel;
panel->show();
close();
}
m_dist += 5;
});
timer->start(15);
}
void Loading::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event)
QPainter p(this);
p.drawPixmap(rect(), m_bk);
p.drawPixmap(62, 417, m_progress.width(), m_progress.height(), m_progress);
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化