Important: Please read the Qt Code of Conduct -

[SOLVED] QProcess special symbols

  • Hello... I have process which execute following command - "cmd /C app.exe --arguments"... It works fine as long as arguments do not contain any special symbols (%&<)... My argument looks like --password "aa<we71%"...
    That argument does not work if I don't convert those special symbols like shown in "this ": website...


    I can change it manually into "aa^<we71%%" and it will work fine... But I want it to be automated... So I would like to know if Qt has any function that would convert string into command line readable text...

    @ QString name = "aa<we71%";

    name.replace("<", "^<");      // replace
    name.replace("%", "%%");  // 2.nd replace
    name.replace("^", "^^");       // 3rd replace


    @I tried with code above but it does not work as supposed... It first replaces < with ^< and new word is "aa^<we71%"... But then in the next 3rd replace it will change ^ into ^^ and that is no longer symbol <...
    I hope you understand what I am saying... So if Qt does not have any function that would do that, how can I do such thing? I could probably put each letter of the word into array and convert one by one and then put them together but that is my last option...

  • Lifetime Qt Champion


    AFAIK, there's no such automatic conversion for special characters. So you would probably need e.g. a regexp to do it

Log in to reply