加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
helpscene.cpp 1.16 KB
一键复制 编辑 原始数据 按行查看 历史
Lewiz 提交于 2022-07-17 22:24 . 帮助界面和部分音效加载
#include "helpscene.h"
helpscene::helpscene(QWidget *parent) : QMainWindow(parent)
{
//设置窗口大小
setFixedSize(MAIN_WIDTH, MAIN_HEIGHT);
//设置图标
setWindowIcon(QIcon(MAIN_ICON));
//设置标题
setWindowTitle(TITLE);
//返回按钮
PushButtonPlus* backBtn = new PushButtonPlus(BACK_BTN1, BACK_BTN2);
backBtn->setParent(this);
//布置到下面
backBtn->move((this->width() - backBtn->width()) * 0.5, this->height() * 0.8);
//信号连接信号
QSound * backBtnSound = new QSound(":/res/BackButtonSound.wav", this);
connect(backBtn, &PushButtonPlus::clicked, this, [this, backBtnSound]()
{
backBtnSound->play();
QTimer::singleShot(100, this, [this]()//加个延时就不卡顿了
{
emit this->backToMainScene();
});
});
}
void helpscene::paintEvent(QPaintEvent *event)
{
//创建画家,指定绘图设备
QPainter painter(this);
//创建 QPixmap 对象
QPixmap pix;
//加载图片
pix.load(HELP_BACK);
//图片拉伸效果
painter.drawPixmap(0, 0, this->width(), this->height(), pix);
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化