I am not sure how this works for Windows:
Code:
if (QFile::exists(filePath) && QFile::exists(application)) {
QStringList arguments = QStringList(QDir::toNativeSeparators(filePath));
return QProcess::startDetached(QDir::toNativeSeparators(application), arguments, QFileInfo(filePath).absolutePath());
}
According to the docs:
Quote:
static] bool QProcess::startDetached(const QString &program, const QStringList &arguments, const QString &workingDirectory = QString(), qint64 *pid = nullptr)
This function overloads startDetached().
Starts the program program with the arguments arguments in a new process, and detaches from it. Returns true on success; otherwise returns false. If the calling process exits, the detached process will continue to run unaffected.
Argument handling is identical to the respective start() overload.
The process will be started in the directory workingDirectory. If workingDirectory is empty, the working directory is inherited from the calling process.
If the function is successful then *pid is set to the process identifier of the started process.
See also start().
|
the third parameter is the working directory the application should be started from. Doesn't it need to be converted to native separators too?
As I read the Qt docs, this will change to that working directory, before launching the application (full path to the application) with the arguments being the full absolute path to the file to be edited.
Not sure what would happen if working directory was given with forward slashes. If wherever that ends up, the user has no executable or write permissions, it would fail I think?
Not sure why this works in Windows 10 unless the working directory parameter is massaged somehow.
Or am I missing something?