Qt: Hello World

So here is the most basic application of Qt: Printing HELLO WORLD !!!!!!

There are two ways of accomplishing that:

using Qt- Creator IDE

using terminal and creating our generating makefile

First the easy one 😛

Using GUI method:-

First create new QT-console project. (console simply means the output will be in form of a console).

name the project as HELLO.and just click next buttons with the default setting of version control and all those stuffs.. Finally you endup with a screen like this:

Hello world example

hello.pro consists of the classes, templates, etc. included in the program.

hello.cpp will contain the actual code which will get executed.
Now, for printing the HELLO WORLD, what i have done is to simply print the output as a debug message on the consol. There are numerous techniques for printing any string. You can also print inside any widget.

So let us build the same application with the non-Graphical approach. For this, there are few steps:

Using non-GUI method: to create an application printing hello world in output:

for this method,you have to export the Qt-compiler to your environment. For this, type:$ export PATH=$PATH:/opt/QtSDK/Simulator/Qt/gcc/bin/
where, /opt/QtSDK/ is the installation folder of Qt. This may vary for others.

Create a folder of same name as your project. — $ mkdir <project_name>

Go to folder — $ cd <project_name>

Open the project name.cpp file — $ vim <name>.cpp

Type code, save your work and exit.

Now since our .cpp file ready,we have to create the <name>.pro file. This is basically a platform-independent project file. — $ qmake -project