[Qt-interest] How to avoid absolute file locations
Syam Krishnan
syamcr at gmail.com
Sat Jan 10 05:07:29 CET 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?
>
Without absolute name, the file is opened from the working directory of
the application.
Available options:
1. The caller should set the working directory properly (using shortcut
in Windows or .desktop file in Linux)
2. If required the application can find out it's own working directory
using the getcwd call (POSIX).
3. Let the caller pass the directoty path as a command line argument.
Your app should have a QString ReferenceDir variable which holds this
path, and use this string to open any files in the application.
Syam
More information about the Qt-interest-old
mailing list