[Solved] Directory path with space
-
wrote on 10 Aug 2014, 14:04 last edited by
Hello friends.
Maybe you think this question is solved more and more before, but I have another problem.
For example the directory path is "C:\Program Files (x86)\sth".
I don`t set it directly! I get it from registry. So, the directory path maybe different in another systems.
How can I change the directory path to a valid one dynamically?Thanks a lot.
Ya Ali. -
wrote on 10 Aug 2014, 18:35 last edited by
Searching a lot and finding nothing major!
But I wrote my own codes.
@
QList<QString> lst = installedPath.split("\");
for(int i=0;i<lst.size(); i++)
{
if(lst.at(i).indexOf(" ") != -1)
{
validLocation += """;
validLocation += lst.at(i);
validLocation += """;
validLocation += "\\";
}
else
{
validLocation += lst.at(i);
if(i != lst.size()-1)
validLocation += "\\";
}
}
@ -
Hi,
There's something not really clear there, what do you mean by set it directly ? How do you retrieve that path in the first place ?
-
wrote on 11 Aug 2014, 00:54 last edited by
Hi dear SGaist,
Thanks for your response.I mean define a QString and give "C:\Program Files (x86)\sth” directly to it:
QSrting location = "C:\Program Files (x86)\sth”.
My project is not like the above because I set the value of location from windows registry. -
How are you accessing the registry and what is the exact string you are getting ?
-
wrote on 11 Aug 2014, 17:06 last edited by
Here is the code:
@
QSettings settings("HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Wireshark", QSettings::NativeFormat);
QString installedPath = settings.value("InstallLocation").toString();
@The result is:
C:\Program Files (x86)\Wireshark -
You can also use QDir::fromNativeSeparators
-
wrote on 12 Aug 2014, 01:25 last edited by
I used but did not work!
1/8