[Solved] Images in qt application not loading.
-
Hello! If anyone is interested or willing to take a look at my code (it's not much) https://dl.dropboxusercontent.com/u/57778776/Working-Copy-Trackbox.zip
I would really appreciate it. The code that is giving my problems is in trackboxmainwindow.cpp and is proceded by a large comment blocks. Thanks. I am so confused in the ways a exact path of a existing file can't be found by qt. -
Hi ,try this:
1.Clean the whole project
2.Run qmake
3.Rebuild the whole projectyour problem sounds like "this":http://qt-project.org/forums/viewthread/28815/
Hope this helps.
-
I will try the clean advice(never a bad idea). This might be part of the problem with my issues in my reasources file, and this will hopefully fix it. Right now I am trying top figure out why qpixmapand qfile thinks a file with a direct path to disk does not exist when the same path works in qtcreator.
-
It's normal it's printing false. You're not escaping the \ in your code.
Anyway since you're using Qt, use the forward slash (yes, like unix) for your paths everywhere and you wont be hit again by this.
-
Duh! I feel like a idiot for not noticing that. That should solve the loading image from disk problem. Next, to see if I can load from reasources.
-
If you have your images in a folder, don't forget to add it in your path
-
musimbate, Thank you so much for your advice. It solved my resource loading problem. Why must you be this way windows?!?
-
That's a question for Microsoft :D
Anyway, if you have everything working now, don't forget to update the thread title prepending [solved] so other forum users may know a solution has been found :)
-
I was running into a problem and it was as simple as running qmake and then re-building, and then viola it worked. I used
@
QFile testIt(":/images/mypict.jpg")
qDebug() << "Are you loading?: " << testIt.exists();
@to verify that the image was NOT loading, but I didn't know why. I searched around for answers but didn't find one that said When you add a resource, you need to re-run qmake.
I'm posting this in case someone else has the same problem.
-
I was running into a problem and it was as simple as running qmake and then re-building, and then viola it worked. I used
@
QFile testIt(":/images/mypict.jpg")
qDebug() << "Are you loading?: " << testIt.exists();
@to verify that the image was NOT loading, but I didn't know why. I searched around for answers but didn't find one that said When you add a resource, you need to re-run qmake.
I'm posting this in case someone else has the same problem.