Problems using QPixmap’s loadFromData to load an image
Trying to use the loadFromData to load an image that’s in a sub-folder where the code looks like this:
I have the folder both in the project’s folder as well as in the debug folder where the debug .exe is (not sure where I’m supposed to have it) and this function always returns false.
Any help would be much appreciated, thanks.
Maybe I miss something, but loadFromData method is used, when you have your picture loaded into memory. Try to use QPixmap::load [qt-project.org] method
Did you try with an full, absolute path in the constructor? Just to make sure, it’s not a “file not found” issue.
If that doesn’t work either, check if the imageformats support PNG. Add in your main method:
- #include <QImageReader>
- qDebug() << QImageReader::supportedImageFormats();
This should list PNG, amongst others.