N3wb
29th December 2010, 23:22
I have a lot of things like QIcons that I need to specify a path->filename for, but I don't want to do an absolute path because the project's directory will not always be constant.
I discovered the QCoreApplication::applicationDirPath() function, which gives the path to the executable file, but my images are a directory above. How can I move up a level? I tried stuff like:
QString temp = QCoreApplication::applicationDirPath() + "../icon.png";
setWindowIcon( QIcon(temp) );
But I haven't had any luck so far.
Is there an easy way to use relative paths for files?
I discovered the QCoreApplication::applicationDirPath() function, which gives the path to the executable file, but my images are a directory above. How can I move up a level? I tried stuff like:
QString temp = QCoreApplication::applicationDirPath() + "../icon.png";
setWindowIcon( QIcon(temp) );
But I haven't had any luck so far.
Is there an easy way to use relative paths for files?