Creating First Application in QT


Open the QT

Select : New File or Project


Chose Template:

Other Project > Empty qmake Project


For New Project Give Name: FirstQTApp


Select all kits


After creation you will get this window.


Now add new


Select c++ source File.


Give name main.cpp


Click on Finish


Once main.cpp file will be create , automatically sources folder will create.


copy below code in FirstQTApp.pro file

QT += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

SOURCES += \

main.cpp


in main.cpp write below code

#include <QApplication>

#include <QLabel>

#include <QWidget>

int main(int argc, char *argv[ ])

{

QApplication app(argc, argv);

QLabel hello("This is my First QT Application");

hello.setWindowTitle("First QT App");

hello.resize(400, 400);

hello.show();

return app.exec();

}

Run the code and get the out as shown in attached image.