PDA

View Full Version : probably a stupid question...



nikita
16th November 2006, 05:57
the thing is that when i start my app from the command line it finds and opens the right files but when i click on the app icon in a window manager (gnome/kde), they don't. do i have to use QDir? thanx.

wysota
16th November 2006, 06:12
You use relative paths. When you click the app icon in the file manager, the current directory is set to your home dir and your application can't find the files it needs. You should either change the current directory back in your app or (what is better) use absolute paths. QCoreApplication::applicationDirPath() may be helpful here.

nikita
16th November 2006, 08:18
i tried to set it with QCoreApplication::applicationDirPath() but i couldn't get it through main(); i finally solved it with QDir setPath in my class implementation :



QDir d;
d.setPath("/path/to/file/");
QFile file(d.filePath("in.txt"));



if you could provide a snip for main() i'll give it a shot. thanx again ;)

wysota
16th November 2006, 09:45
QString mypath = QCoreApplication::applicationDirPath()+"/myimage.png";