An important note when downloading a file using directly "adadad.jpg" in your code. Even if you put the file in the debug / release folder, QImage will always be NULL if it is loaded this way.
I ran into this problem yesterday and I fixed it using the Qt library to get the full path: QCoreApplication::applicationDirPath() .
There are two ways to achieve this, first, when you create an img object.
QImage img( QCoreApplication::applicationDirPath() + "adadad.jpg"); if( img.isNull()) { qDebug() << "Loading Error - file: adadad.jpg."; return false; }
or using the download function
QImage img; if( !img.load(QCoreApplication::applicationDirPath() + "adadad.jpg")) { qDebug() << "Loading Error - file: adadad.jpg."; return false; }
source share