0

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?

user2653062
  • 697
  • 1
  • 9
  • 16
  • @N1ghtLight. A little more detail. I am building on **Mac**. After the new process gets started, my application's window disappeares but remains docked in the dock. I want the application to be fully closed. – user2653062 Oct 15 '14 at 21:11

2 Answers2

3

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).

Max Go
  • 2,092
  • 1
  • 16
  • 26
1

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();
    }
trivelt
  • 1,913
  • 3
  • 22
  • 44