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.
{
QString location
[4] = {"No",
"C:/Program Files/Program",
"C:/Program Files(x86)/Program",
"~/.wine/drive_c/Program Files/Program"};
#ifdef Q_MS_WIN //case of windows
if (dir.exists(location[1])) //case it's 32 bit
return location[1];
if (dir.exists(location[2])) //case it's 64 bit
return location[2];
#endif
#ifdef Q_WS_X11 //case of linux -> this one gives me problems
if (dir.exists(location[3]))
return location[3];
#endif
return location[0];
}
QString Program::ProgramFound()
{
QDir dir();
QString location[4] = {"No", "C:/Program Files/Program", "C:/Program Files(x86)/Program", "~/.wine/drive_c/Program Files/Program"};
#ifdef Q_MS_WIN //case of windows
if (dir.exists(location[1])) //case it's 32 bit
return location[1];
if (dir.exists(location[2])) //case it's 64 bit
return location[2];
#endif
#ifdef Q_WS_X11 //case of linux -> this one gives me problems
if (dir.exists(location[3]))
return location[3];
#endif
return location[0];
}
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:
{
QString location
[4] = {"No",
"C:/Program Files/Program",
"C:/Program Files(x86)/Program",
"~/.wine/drive_c/Program Files/Program"};
#ifdef Q_MS_WIN //case of windows
if (dir.exists(location[1])) //case it's 32 bit
return location[1];
if (dir.exists(location[2])) //case it's 64 bit
return location[2];
#endif
#ifdef Q_WS_X11 //case of linux -> this one gives me problems
if (dir.exists(location[3]))
return location[3];
#endif
return location[0];
}
QString Program::ProgramFound()
{
QString location[4] = {"No", "C:/Program Files/Program", "C:/Program Files(x86)/Program", "~/.wine/drive_c/Program Files/Program"};
#ifdef Q_MS_WIN //case of windows
QDir dir();
if (dir.exists(location[1])) //case it's 32 bit
return location[1];
if (dir.exists(location[2])) //case it's 64 bit
return location[2];
#endif
#ifdef Q_WS_X11 //case of linux -> this one gives me problems
QDir dir();
if (dir.exists(location[3]))
return location[3];
#endif
return location[0];
}
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.
Bookmarks