Solved Build errors in tutorial sample project
-
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();
}- I tried to build it and I got compilation errors: QApplication: file not found
QPushButton: file not found
..... - I opened the project file and found only lines of:
SOURCES +=
main.cppNot as in tutorial:
TEMPLATE = app
TARGET = name_of_the_appQT = core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
SOURCES += main.cpp
How come?
- I tried to build it and I got compilation errors: QApplication: file not found
-
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.
-
I modified project file as you said and it works then. Thanks.