PDA

View Full Version : Files in the project folder won't open...



danoc93
20th January 2012, 00:14
If I use a Qlabel to insert an image in my frame, or a txt, it can't be in the project folder or they won't show up once i press ctrl r....

It's weird... I have to use images from other folders... but that's not good since I don't want to have to create the folders on every computer I take my program to...

Lesiok
20th January 2012, 07:00
Read about resources (http://developer.qt.nokia.com/doc/qt-4.8/qresource.html)

ChrisW67
20th January 2012, 20:46
The current working directory of the running application (QDir::currentPath()) is not necessarily, or even usually, the same as the source code directory or the directory containing the executable (QCoreApplication::applicationDirPath ()). If you open files using relative paths then they will break if the directory is not what you expect. Use resources if the data is fixed, or a smarter way to find the file and error checking otherwise.