Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Build errors in tutorial sample project
Forum Update on Monday, May 27th 2025

Build errors in tutorial sample project

Scheduled Pinned Locked Moved Solved Installation and Deployment
3 Posts 2 Posters 440 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Stan HuangS Offline
    Stan HuangS Offline
    Stan Huang
    wrote on last edited by
    #1

    I followed steps in tutorial: https://wiki.qt.io/Qt_for_Beginners
    I built the first project (File --> New File or Project --> Other projects --> Empty QMake Project --> ...) I created a source file main.cpp as indicated in the tutorial.
    main.cpp:
    #include <QApplication>
    #include <QPushButton>

    int main(int argc, char **argv)
    {
    QApplication app (argc, argv);

    QPushButton button ("Hello world !");
    button.show();

    return app.exec();
    }

    1. I tried to build it and I got compilation errors: QApplication: file not found
      QPushButton: file not found
      .....
    2. I opened the project file and found only lines of:

    SOURCES +=
    main.cpp

    Not as in tutorial:

    TEMPLATE = app
    TARGET = name_of_the_app

    QT = core gui

    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

    SOURCES += main.cpp

    How come?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      The tutorial says:
      In a project file, there is some minimal code that should always be written :

      TEMPLATE = app
      TARGET = name_of_the_app
      
      QT = core gui
      
      greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
      

      Which means that you have to add it to your project because as the name of the template suggests, it's an empty project to get you started.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2
      • Stan HuangS Offline
        Stan HuangS Offline
        Stan Huang
        wrote on last edited by
        #3

        I modified project file as you said and it works then. Thanks.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved