qt

Directory path with space


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.


Solution

  • 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 += "\\\\";
            }
        }