Question

I built and executed the application (code bellow), and the splash screen shows gray, instead of the image. I didn't know where is the problem although the path of the image is correct.

This is my 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();
}
Was it helpful?

Solution

There are two options :

  • you either didn't parse and compile the resource file (with rcc to parse)
  • or you put wrong path in the qrc file to your image (see qt resources), or you didn't add it at all

As I said, try to use an image from a disk. If it displays fine, then it is one of the above problem.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top