Friday, October 30, 2015

Hello World Qt, hand made from Empty qmake Project

This video show how to create Empty qmake Project in Qt Creator, create .cpp and edit .pro to make a Hello World application.


main.cpp

#include <QApplication>
#include <QPushButton>

int main(int argc, char *argv[]){
    QApplication app(argc, argv);
    QPushButton qPushButton("Hello Qt");
    qPushButton.show();
    return app.exec();
}


You will be reported with error of:
QApplication: No such file or directory
QPushButton: No such file or directory

To fix it: Edit HelloQt.pro to add the code QT+=widgets.
QT+=widgets
SOURCES += \
    main.cpp