P
P
Profi_GMan2018-01-27 23:07:54
Qt
Profi_GMan, 2018-01-27 23:07:54

How to run QProcess::start() from a non-main thread?

Good day!
And again I have a question. Because I'm too inexperienced and on the go, I don't know how to google correctly.
How to run QProcess::start() from a non-main thread? And the name is from QConcurrent::run()
I do this:

QConcurrent::run([=]() {
    QProcess proc;
    proc.start(...);
});

But I often have crashes. Often, but not always - every other time.
How to get rid of crashes? Only by signals to the main thread (I just already have a lot of lines of code and it's somehow crooked)?
Thanks a lot!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ighor July, 2018-01-28
@Profi_GMan

QProcess proc;
proc.startDetached(...);
proc.waitForStarted();
Or
QProcess proc;
proc.start(...);
proc.waitForStarted();
proc.waitForFinished(-1);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question