我构建并执行了应用程序(代码如下),并且闪屏显示灰色而不是图像。尽管图像的路径是正确的,但我不知道问题出在哪里。灰色矩形代替飞溅Qt
这是我的main.cpp:
#include <QApplication>
#include<QSplashScreen>
#include "mainwindow.h"
#include <unistd.h>
int main(int argc, char* argv[])
{
QApplication app(argc, argv);
QPixmap pixmap(":/images/splash.png");
QSplashScreen splash(pixmap);
splash.setMask(pixmap.mask());
splash.show();
app.processEvents();
sleep(5);
MainWindow window;
window.show();
app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()));
splash.finish(&window);
return app.exec();
}
你是什么意思,“在构建过程中,它显示我总是一个灰色的矩形而不是飞溅”? –
当我运行应用程序,而不是看到主窗口之前的splashscreen ..我只看到一个灰色的矩形和我的主窗口后 @BЈовић – tissa
你如何建立?你解析和编译资源了吗?尝试从文件加载图像。 –