Congratulations to our 2022 Qt Champions!

[Solved] No access to qApp

  • I've got a pretty simple application, but I'm not able to see the global variable, qApp. My main function is very simple:
    int main(int argc, char *argv[])
    QApplication a(argc, argv);
    MainWindow w;;

    return a.exec();


    Then, inside the constructor of w (a QMainWindow) I'm trying to set up a translation and have the line:

    It tells me that qApp has not been declared in this scope. I thought it was automatically declared without me having to do anything. Why can't I access it?

  • add @#include <QApplication>@ in your MainWindow class. qApp is available wherever it is included.

  • Knew it had to be something simple - Thanks!

Log in to reply