user2653062
user2653062

Reputation: 717

Qt: How to close application after starting a new process?

I am starting a new process from my application using QProcess::startDetached(). After this new process is started, I want my application to exit. How do I do that?

Upvotes: 0

Views: 958

Answers (2)

trivelt
trivelt

Reputation: 1965

Keep in mind, that calling QProcess::startDetached() doesn't mean that new process is started. You should check returned value of this method:

bool isStarted = QProcess::startDetached(commandString);
if(isStarted)
    {
    qApp->quit();
    }

Upvotes: 1

Max Go
Max Go

Reputation: 2102

You can use qApp macro as following: qApp->quit();

QApplication or QCoreApplication header should be included.

void QCoreApplication::quit () [static slot]

Tells the application to exit with return code 0 (success). Equivalent to calling QCoreApplication::exit(0).

Upvotes: 3

Related Questions