Question

I am coding a GUI using Qt. When I run the application using QtCreator, my images do not load, and I receive the following error:

QPixmap::scaled: Pixmap is a null pixmap

Yet, when I run the application via command line, everything displays perfectly.

Why so? And how can I get QtCreator to load my images properly?

NB: Those images are barely 20ko each, so what I read about images being too big can't apply.

EDIT: A typical filename is 'Images/Cards/Base/card01.jpg', where Images is a subdirectory of my project directory (the code being at the root)

Was it helpful?

Solution

If you are working with images that should be bundled with the application, such as icons, then you should try and make use of the Qt Resource system.

This allows you to build the resources into the actual project and reference them in a filesystem independent syntax. i.e.: :/icons/myIcon.png

Most likely you have a difference between the relative location of the file in Qt Creator vs the command line.

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