Restarting a Qt app programmatically

I had a requirement to restart some Qt apps remotely. This kind of thing can be a little tricky in a multi-platform environment but of course Qt makes it nice and easy – just four lines of code:

    QStringList args = QApplication::arguments();
    QProcess::startDetached(QApplication::applicationFilePath(), args);

The removeFirst() is needed because the first string in the list is the app name – the result is just the arguments that were originally passed to the app.