Qt Tutorials For Beginners – Create First Qt Application




Qt Tutorials For Beginners
Qt Tutorials For Beginners

In this tutorial we will learn how to create our first qt application.

Step 1 – File->Other Project->Empty Qt Project

Step 1 - Open Qt , Select File and click New
Step 1 – Open Qt , Select File and click New

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Step 2 - Select Other Project and Click Empty qmake Project
Step 2 – Select Other Project and Click Empty qmake Project

 

 

Step 3 - Give name to your project and Click next
Step 3 – Give name to your project and Click next

When we create a Empty Qt Project There is nothing in the Project explorer, and even the .pro file has nothing in it. So, we need to create a main.cpp file.

Step 2 – Right Click on Project -> Add New -> C++ -> C++ Source file -> Choose

And Give the name main.cpp file and press finish.

main.cpp

#include <QApplication>
#include <QLabel>
#include <QWidget>
int main(int argc, char *argv[ ])
{
    QApplication app(argc, argv);
    QLabel hello("Hello World");
    hello.setWindowTitle("My First Qt Program");
    hello.resize(400, 400);
    hello.show();
    return app.exec();
}

 

HelloWorld.pro

QT += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

SOURCES += \
    main.cpp

Output

Output - Create First Qt Application
Output – Create First Qt Application

Partner Sites

VideoToGifs.com

EasyOnlineConverter.com

SqliteTutorials.com





1 Comment

  1. hi i tried but it does not work at all on Qt on me this code displays “14:50:04: Running steps for project testQtdeveloppement…
    14:50:04: Configuration unchanged, skipping qmake step.
    14:50:04: Starting: “C:\Qt\Qt5.3.0\Tools\mingw482_32\bin\mingw32-make.exe”
    C:\Qt\Qt5.3.0\5.3\mingw482_32\bin\qmake.exe -spec win32-g++ -o Makefile ..\testQtdeveloppement\testQtdeveloppement.pro
    C:/Qt/Qt5.3.0/Tools/mingw482_32/bin/mingw32-make -f Makefile.Release
    mingw32-make[1]: Entering directory ‘C:/Qt/Qt5.3.0/Tools/QtCreator/bin/build-testQtdeveloppement-Desktop_Qt_5_3_0_MinGW_32bit-Release’
    g++ -c -pipe -fno-keep-inline-dllexport -O2 -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN -I..\testQtdeveloppement -I”..\..\..\..\5.3\mingw482_32\include” -I”..\..\..\..\5.3\mingw482_32\include\QtWidgets” -I”..\..\..\..\5.3\mingw482_32\include\QtGui” -I”..\..\..\..\5.3\mingw482_32\include\QtCore” -I”release” -I”.” -I”..\..\..\..\5.3\mingw482_32\mkspecs\win32-g++” -o release\main.o ..\testQtdeveloppement\main.cpp
    Makefile.Release:232: recipe for target ‘release/main.o’ failed
    process_begin: CreateProcess(NULL, g++ -c -pipe -fno-keep-inline-dllexport -O2 -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN -I..\testQtdeveloppement -I..\..\..\..\5.3\mingw482_32\include -I..\..\..\..\5.3\mingw482_32\include\QtWidgets -I..\..\..\..\5.3\mingw482_32\include\QtGui -I..\..\..\..\5.3\mingw482_32\include\QtCore -Irelease -I. -I..\..\..\..\5.3\mingw482_32\mkspecs\win32-g++ -o release\main.o ..\testQtdeveloppement\main.cpp, …) failed.
    make (e=2): Le fichier spécifié est introuvable.

    mingw32-make[1]: *** [release/main.o] Error 2
    mingw32-make[1]: Leaving directory ‘C:/Qt/Qt5.3.0/Tools/QtCreator/bin/build-testQtdeveloppement-Desktop_Qt_5_3_0_MinGW_32bit-Release’
    mingw32-make: *** [release] Error 2
    Makefile:34: recipe for target ‘release’ failed
    14:50:06: The process “C:\Qt\Qt5.3.0\Tools\mingw482_32\bin\mingw32-make.exe” exited with code 2.
    Error while building/deploying project testQtdeveloppement (kit: Desktop Qt 5.3.0 MinGW 32bit)
    When executing step ‘Make’
    14:50:06: Elapsed time: 00:02.”

Leave a Reply

Your email address will not be published.


*