[Qt-interest] How to avoid absolute file locations

Alan M. Carroll amc at network-geographics.com
Sat Jan 10 23:11:55 CET 2009


What I would do is presume a fixed relative structure. E.g. there is an app directory under which is a "bin" directory and "data" directory. The QT application goes in "bin" and the data files in "data". 

The code can use the QCoreApplication::applicationDirPath() static method to get the path to the executable. From that it's trivial to back track up to the application root directory then down to the "data" directory. With this set up, you can create a tar ball which will work no matter where in the file system it is unpacked.

At 07:47 PM 1/9/2009, Samuel G wrote:
>With the two files above, opening the file fails on line 8. What is
>the Qt way to read program data without using an absolute file
>location?




More information about the Qt-interest-old mailing list