Using external data-files in programs

Kevin Krammer kevin.krammer at
Sun Jul 25 15:20:07 BST 2004

On Saturday 24 July 2004 20:38, Erlend Hamberg wrote:
> How can I write programs that use external data-files which can be run
> from konqueror by (double) clicking on them?
> I usually have sounds and images in a directory called "data" and open
> the files from my program using a relative path, but when I run them
> from konqueror the program can't open the files in "data/". So
> whenever I give a program to some friends or something they have to
> open a terminal and browse to the directory containing the executable
> file before they can run the program.

Not sure if I understood you right.
You ask about how to manage standard data files of an application, for example 
icons, etc.

KDE programs do this through the KStandardDirs class or the convenience 
function locate() (also declared in kstandarddirs.h)

A program not using kdelibs can use the base dir specification
to install its data files into locations where it can find them at runtime.

Another option is to start a wrapper script instead of the real application 
executable and have the wrapper script switch the workign directory so that 
paths to resources can be relative.

Other options would be to search standard paths like /usr/share/appname or 
/usr/local/share/appname or read the base path from a config file.


Kevin Krammer <kevin.krammer at>
Qt/KDE Developer, Debian User - Unix/Linux programming forum - Qt programming forum
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: signature
URL: <>
-------------- next part --------------
This message is from the kde mailing list.
Account management:
More info:

More information about the kde mailing list