[Qt-interest] How to avoid absolute file locations
Samuel G
samuel857 at gmail.com
Sat Jan 10 05:12:42 CET 2009
Thanks, Brad: there were several nice suggestions in your email.
It is indeed a GUI application. The data files are a few 3D models and
a few texture images. I would like to be able to distribute my code to
others as a tar-ball and not worry about where on their system they
choose to compile/run it.
Let me look at your suggestions one by one.
Embedding the file as a resource is the most promising. You are
suggesting to replace the data file (in the example) with:
const char * const MYDATA = {
"2\n"
"3\n"
};
...
QTextStream in(MYDATA);
This is nice for icons. It is also all right for the 3D models,
but it is a bit tedious for larger images.
Asking the user to select the location of the files from the file
system, before running the program even once, is not too friendly.
Neither is passing the path/file name on the command line.
Using a configuration file would be a one-spot solution, but then the
same problem falls back to that configuration. How would its own
location be specified?
Samuel
More information about the Qt-interest-old
mailing list