You are creating a local QApplication object that goes out of scope immediately afterwards. The run() method doesn't make sense too - "if there is no qApp, call qApp".