PDA

View Full Version : Having Troubles with QDir and the absolutePath



DiegoTc
2nd January 2011, 07:45
Hi everyone
I am having this small problem.
I have a folder name IMPORTANT, this folder is located on the main project folder(where the source code is located).

In this folder, I have a file that I have to open on the application I am doing, here it comes my problem.

I use QDir, and give the path where the File is located

QDir dir("/home/diego/Projects/code/IMPORTANT");
and the rest of code.

This works perfect. But here is my problem, what happens if I want to give this code to one friend of my, it will not run on his computer because he doesn't have this address /home/diego/Projects/

So what I can do to solve this problem?
Can someone give me an idea?
Thanks

boudie
2nd January 2011, 10:03
You could use the application directory to store that file. You can find it with:
QCoreApplication::applicationDirPath ()

Or use the users homedir:
QDir::homeDirPath ()

wysota
2nd January 2011, 12:13
Or something relative to any of those.