Congratulations to our 2022 Qt Champions!

Problem with Qt empty projet

  • Hello every body,

    i have a little problem with Qt. when i open a new project, i choose empty project Qt.
    i then when it is open i can't include QApplication i don't know why ? can you help me please.

  • Moderators


    I recommend starting with a "Qt Gui Application" or a "Qt Console Application" instead of a blank project. If you choose those, Qt Creator will help you set up some important parts.

    But to answer your question:

    Your .pro file is empty. You need to add the modules you want. All Qt projects automatically include the Qt Core and Qt GUI modules, but you'll need to add other modules yourself.

    QApplication belongs in the Qt Widgets module. To include that, add the line "QT += widgets" to your .pro file.

  • The solution is adding this

     QT += widgets

    line to your *.pro file, as JKSH said. Don't forget to save it and you'll be able now to include <QApplication> module to your main.cpp

Log in to reply