Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
photos in qt application aren't loading (linux)
noammm last edited by noammm
I am trying to add photos, but all the ways i tried to far didn't work
I tried with this code (and some other that I didn't save)
QPixmap photo("/home/noam/project/test/photo.png"); ui->label->setPixmap(photo);
but it doesn't work (I tried also with jpg photos)
when I checked if the path is good, so it is good -
QFile photo("/home/noam/project/test/photo.png"); qDebug() << "Are you loading?: " << photo.exists();
it returns true
any ideas what can be the problem ?
I tried many ways, but just nothing works..
at first i thought that maybe it is because I'm using linux but when i searched on google, I didn't find someone else who has that problem because linux
Thanks in advance,
strange. Is it a image format issue ? Can you try loading with qpixmap load API ? See if this is successful ? Hope nobody meddled with plugins/image formats directory. If plugins are missing nothing works.
kenchan last edited by
Did you try to build the Image Viewer Example app from the list of examples available in QtCreator?
This uses a pixmap on a QLabel so if this does not work you may have a problem with your Qt installation. If it does work you probably have a problem with your project.
here is a link to the online docs
@noammm Did you check the image file? Is it valid and can be viewed with an image viewer?
qDebug() << photo.isNull();
Make sure you can open the image file with
noammm last edited by
@kenchan thanks for your fast answer ! so it definitely helped because now I got another error (at least there is something new)
it says unable to get data, and maybe it's explaining why I got "true" when I checked isNull (but I still get true when I check with exists())
Do you know what can be the reason ? I'm really a beginner with qt and I don't know much about how it works and what can make this problem
kenchan last edited by kenchan
Well, that probably means the Qt reader cannot read your png file. It may be corrupted or an unsupported bit depth?
Can you post the image somewhere so we could download it and try it for ourselves.