QSplashScreen 在 arm板上不显示或闪现问题解决方法
QSpalashScreen是QT 的一个模块,可以用于显示应用程序启动图片提示信息等
网上使用例程有很多,测试在Windows 下显示正常
#include "impellamainwindow.h"
#include <QApplication>
#include <QSplashScreen>
int main(int argc, char *argv[])
{
qputenv("QT_IM_MODULE", QByteArray("tgtsml"));
QApplication a(argc, argv);
QSplashScreen *splash = new QSplashScreen;
//splash->setPixmap(QPixmap(":/system_pop_up/standby.png"));//设置图片
splash->setPixmap(QPixmap("C:/BaiduNetdiskDownload/Share/Impella/pictures/system_pop_up/standby.png"));//设置图片
splash->show();//显示图片
Qt::Alignment topRight = Qt::AlignRight | Qt::AlignTop;
splash->showMessage(QObject::tr("主界面初始化中..."),topRight, Qt::white);//显示信息
ImpellaMainWindow w;
w.show();
splash->finish(&w);//图片一直显示到mainWin加载完成
delete splash;//释放空间,节省内存
return a.exec();
}
上述代码在arm下使用时 则无法正常显示,实测在w.show();之前闪现了一下
网上很多人说要delay,这不纯纯要人命吗?本来就慢,你还要delay。
解决方法参考:
https://bbs.youkuaiyun.com/topics/394466028
修改代码后可以正常显示,
主要区别1. 添加代码 a.processEvents();
splash->finish(&w); 放在 window 实例化之后,w.show之前。
#include "impellamainwindow.h"
#include <QApplication>
#include <QSplashScreen>
#include <QPixmap>
int main(int argc, char *argv[])
{
qputenv("QT_IM_MODULE", QByteArray("tgtsml"));
QApplication a(argc, argv);
QPixmap pixmap(":/system_pop_up/pictures/system_pop_up/standby.png");
QSplashScreen *splash = new QSplashScreen(pixmap);
// splash->setPixmap(QPixmap(":/system_pop_up/pictures/system_pop_up/standby.png"));//设置图片
splash->show();//显示图片
a.processEvents();
ImpellaMainWindow w;
splash->finish(&w);//图片一直显示到mainWin加载完成
w.show();
delete splash;//释放空间,节省内存
return a.exec();
}