QString replace %U
-
I found the reason: QProcess->setProgram(sExec), sExec can not contain space, if not will fail to start.
Program and arguments must separated!sExec = sExec.left(sExec.indexOf(" ")); connect(action, &QAction::triggered, [=](){ QProcess *process = new QProcess; process->setWorkingDirectory(path); qDebug() << sExec; process->setProgram(sExec); process->setArguments(QStringList() << filepath); bool b = process->startDetached(); qDebug() << b; });@sonichy said in QString replace %U:
QProcess->setProgram(sExec), sExec can not contain space, if not will fail to start.
Not true. Space in the path to or name of the executable is fine.
Program and arguments must separated!
Which is why I told you earlier
That line is not a program/executable, is it? The first word is the executable and the second word is an argument
And that is why I would like you to read what we write and act on it, not just do nothing about it.....
Whole of your lambda body code with
QProcess *process = new QProcessonward could be replaced with just one line:QProcess::startDetached(sExec, QStringList() << filepath, path);if you want to avoid the memory leak.