Reputation:
I want to let QProcess run many command at a time,instead of one at a time.
void Route::add_route()
{
QProcess *Add_route = new QProcess(this);
Add_route->start("notepad",QStringList() << "interface" << "ipv4" << "set" << "interface" << "" << "metric=1");
Add_route->start("explorer",QStringList() << "interface" << "ipv6" << "set" << "interface" << "" << "metric=1");
Add_route->waitForFinished();
}
By using this,it will only run the first one.
Ps: I'm using notepad and explorer just for test
Thanks!
Upvotes: 0
Views: 538
Reputation: 37512
QProcess
as name suggest represents single process not multiple.
So your requirement to run two processes using single QProcess
object is faulty by design.
You have two choices:
QProcess
, one for each process "command"Upvotes: 0
Reputation: 865
QProcess has a member-function startDetached()
. Use one QProcess for every process you need to start, not one QProcess for all processes. See http://doc.qt.io/qt-5/qprocess.html#startDetached
Upvotes: 2