Creating CIRCLE using Qt Creator 2.7.2(based on QT 5.1.0) in UBUNTU 13.04

Qt Creator is an integrated development environment (IDE) that provides you with tools to design and develop applications with the Qt application framework. Qt is designed for developing applications and user interfaces once and deploying them across several desktop and mobile operating systems. Qt Creator provides you with tools for accomplishing your tasks throughout the whole application development life-cycle, from creating a project to deploying the application on the target platforms.

"Qt Creator overview"

I have created  simple circles using Qt-Creator in two ways.

1.)using Qt Gui Application(using Qwidget)

2.)using non-Qt project(using Qmainwindow)

PREREQUISITES:

Before you need to self-perform the task,you need to do any one of the following(a> or b>):

a>clone my repository from github(in case you do not wish to indulge in writing a programs) using this link:

https://github.com/albertcoder/Qt

Once you have cloned this repository, you can directly open the project in Qt-Creator from its location. In this case you will only need to “build” and “run”.

b>write your own C++ program(since this example is based on C++) for circle(or any figure of your choice) prior to proceeding.

PROCEDURE TO DRAW THE CIRCLES:

1.)using Qt Gui Application(using Qwidget):

i.)Open file>New File or Project>Applications>Qt Gui Application.

ii.)Then select “choose”. After that set the name and location of your project and click “next”.

iii.)Then a window titled “Qt Gui Application” will appear asking Kit Selection, click “next”.

iv.)This will follow a window again titled “Qt Gui Application” asking for Class Information. Here in the Base class option we have to select “Qwidget” as we desire to make a widget and use it for displaying the output of our program.

v.)After this click “next”  click “finish” (we can also select git or mercurial from Add to version control) and we are almost done.

vi.)Now write your code for circle in file “widget.cpp” which you can open by clicking on sources from the left vertical pane after expanding your project(master). See this screen shot in case you are new to Qt-aura(this might help).

widget.cpp

vii.)Then select the “build” option(hammer shaped button in leftmost vertical column/pane).

viii.)Now select “run” option(green colored triangular button like play button in music players).

You can also do the steps vii.) and viii.) using build option from toolbar(horizontal pane on the top) .

Once you run your program(step viii), a widget will appear with circles(or any other output according to your program) drawn on it.

2.)using non-Qt project(using Qmainwindow):The procedure is almost same as above.

i.)Open file>New File or Project>Non-Qt Project>Plain C++ Project.

ii.)Then select “choose”. After that set the name and location of your project and click “next”.

iii.)Then a window titled “Plain C++ Project” will appear asking for Kit Selection,just click “next”.

iv.)After this click “next” and click “finish” (we can also select git or mercurial from Add to version control) and we are done.

v.)Now write your code for circle in file “main.cpp”(as you wrote in widget.cpp in the above example,step vi).

vi.)Then select the “build” option(hammer shaped button in leftmost vertical column/pane).

vii.)Now select “run” option(green colored triangular button like play button in music players).

You can also do the steps vi.) and vii.) using build option from toolbar(horizontal pane on the top) .

Once you run your program(step vii), a qmainwindow will appear with circles(or any other output according to your program) drawn on it.

And this is the screen-shot of the circles drawn: The rectangular window(on your left) denotes “Qmainwindow”as you can see and the square window(on your right) titled circle denotes “widget”

Image

In case you need to know more about the difference between a widget and qmainwindow refer to the following:

http://qt-project.org/doc/qt-4.8/application-windows.html

http://ubuntuforums.org/showthread.php?t=1428639

Thanks

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s