qt: Fix use of dangling pointer in QApplication