Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
[SOLVED] Start QProcess out of QML Issue
I would like to start an application out of Qt Quick and check if it was started successfully or if it was closed by the user. So I wrote a small plugin to access Qt's QProcess functionality out of Qt Quick. It works for starting some applications, but when I check whether the application is running, it always says true (also when not running). What's wrong here?
void Launcher::launch(const QString &program, const QStringList &arguments)
return m_process->Running? true : false;
Thank you for your help.
You should use state() to check the current state and not the enum value.
return m_process->state()==QProcess::Running ? true : false;
Edit: Removed Extra =
My program crashes if I read out the m_process->state(). I don't understand this... Do you have any idea for that problem?
Probably because the object is not initialized. Put a condition to check if it is null before the return statement.
Works perfectly, thank you!:)
Another error was to use startDetached() instead of start().
Glad that it worked :)
Please mark the post as solved by editing the post title and prepend [solved]