QT 4.7.0 (64bit)
Slackware 13.1 (actually it's -current though wasn't sure if someone would be "what version is -current???")

I'm trying to make a simple function that will test if folder of a certain program exists and I'm getting a problem that I'm not sure how to deal with.

Qt Code:
  1. QString Program::ProgramFound()
  2. {
  3. QDir dir();
  4. QString location[4] = {"No", "C:/Program Files/Program", "C:/Program Files(x86)/Program", "~/.wine/drive_c/Program Files/Program"};
  5. #ifdef Q_MS_WIN //case of windows
  6. if (dir.exists(location[1])) //case it's 32 bit
  7. return location[1];
  8. if (dir.exists(location[2])) //case it's 64 bit
  9. return location[2];
  10. #endif
  11. #ifdef Q_WS_X11 //case of linux -> this one gives me problems
  12. if (dir.exists(location[3]))
  13. return location[3];
  14. #endif
  15. return location[0];
  16. }
To copy to clipboard, switch view to plain text mode 

I get for line 12 following error:
error: request for member 'exists' in 'dir', which is of non-class type 'QDir()'
At global scope:
Thought that QDir in this case doesn't exit the scope of first #ifdef which was kinda weird considering that I defined it outside of it, so I tried to place QDir dir in both of those:

Qt Code:
  1. QString Program::ProgramFound()
  2. {
  3. QString location[4] = {"No", "C:/Program Files/Program", "C:/Program Files(x86)/Program", "~/.wine/drive_c/Program Files/Program"};
  4. #ifdef Q_MS_WIN //case of windows
  5. QDir dir();
  6. if (dir.exists(location[1])) //case it's 32 bit
  7. return location[1];
  8. if (dir.exists(location[2])) //case it's 64 bit
  9. return location[2];
  10. #endif
  11. #ifdef Q_WS_X11 //case of linux -> this one gives me problems
  12. QDir dir();
  13. if (dir.exists(location[3]))
  14. return location[3];
  15. #endif
  16. return location[0];
  17. }
To copy to clipboard, switch view to plain text mode 

And got same error. Then I tried to switch #ifdef's. So linux one was first one and windows was second and expected to get error for dir.exists in windows #ifdef but I got same error for linux again and got little lost.

In case that I changed Q_WS_X11 to anything else, like Q_MS_X11, program would compile but it wouldn't work on linux considering that Q_MS_X11 isn't right global.

So... just wondering if someone could point me to right direction on how should I deal with it?
And information on how to improve the function is welcomed too though don't be too harsh I'm just a beginner.