Refactor QApplication creation and fix lifetime of its args.