qmake does not add widgets

c++, qmake, qt, qt5, qtwidgets

Solution

how can i do this? i dont want to add manually.

You can do the following things:

1) You could use QtCreator and select the widget based application.

2) qmake -project "QT += widgets"

but nothing more. QMake is not a C++ code project parser.

Also, note that you could use `greaterThan(QT_MAJOR_VERSION, 4):QT+=widgets` to be compatible with Qt 4 if that matters for you since the widgets were in the gui module for Qt 4 and core and gui are added by default. They were put into their own widgets module in Qt 5.

Problem

i have a simple program. my program is: ``` #include <QApplication> #include <QLabel> int main(int argc, char *argv[]) { int rc ; QApplication app(argc, argv); QLabel *label = new QLabel("Hello Qt!"); label->show(); rc = app.exec(); return(rc) ; } ``` i want to compile and build this code in command line. i have installed qt and mingw. first my command is: ``` qmake -project ``` then i give this command. ``` qmake ``` then qmake creates .pro file which is: ``` TEMPLATE = app TARGET = HELLO INCLUDEPATH += . # Input SOURCES += hello.cpp ``` i think this file must inclue ' QT += widgets' but it doesnt. i dont know why. finally, i call mingw make and it gives error. when i add .pro file QT += widgets then call mingw-make, it works and creates .exe file. then my question is that, why qmake automatically add `QT += widgets` , how can i do this? i dont want to add manually.

Original source