# Getting Started With Qt

Hi guys,

Qt is a cross-platform application framework used extensively for developing non-GUI programs and consoles for servers. It is written in C++ and works on major platforms including Android, iOS, Windows and more recently Sailfish MeeGo Linux. There exists three versions of Qt available on each of these platforms, namely:

GUI Framework – commercial entry level GUI edition, stripped of network and database support (formerly named “Desktop Light”)

Full Framework – complete commercial edition Open Source – complete Open Source edition

The latest version of Qt (Qt 5.2) now includes new functionalities for KDE Frameworks 5 and hardware accelerated graphics. In this tutorial, we will learn how to start using Qt on Windows with the help of a sample program.

Pre-requisites: Windows 7 (64 bit)

Step 1: Download Qt for Windows

To start programming using Qt, you need to download the binaries for either MingGW or Visual Studio from over here. You can choose an offline or an online installer depending upon your operating system. After you have successfully installed Qt, you need to open the Qt Creator application.

Note: Qt Creator is a cross-platform IDE for C++ and QML. Qt Designer’s GUI layout/design functionality is integrated into this relatively new IDE.

Step 2: Create Qt console application project

Go to File–>New File or Project and create a new Qt console application named TestQt. In case you installed Qt with Visual Studio, you should see the compiler kit already loaded. Qt creator uses the default Desktop kit for creating console applications.

Step 3: Write a sample program

Now, let’s write a simple Qt Hello World program. Open the main.cpp file and add the following code!

#include <QApplication>
#include <QtWidgets/QPushButton>

int main(int argc, char **argv)
{
QApplication app (argc, argv);

QPushButton button ("Hello world !");
button.show();

return app.exec();
}


*.pro file


QT  += core

QT  -= gui

QT  += widgets

TARGET = TestQt
CONFIG   += console
CONFIG   -= app_bundle
TEMPLATE = app

SOURCES += main.cpp


Right click your project and run qmake. Now, build your project. If no build errors are present then run the application to see the following output!

Qt is currently available under GPL v3, LGPL v2 and a commercial license. It is developed by Digia, who owns the Qt trademark, and the Qt Project under open governance, involving individual developers and firms working to advance Qt. Thanks for visiting! :)

Reference: Qt software