How to use Qt GUI framework for projects

WTF is this?

This is my attempt to write a walkthrough for total beginners who are starting their project and want to move quickly forward to solution of a real problem. I hope it could help avoid hours spent by exploring how to write a GUI, which his or her supervisor want to have in the project. I expect you use Windows XP OS and you want to use nice IDE for developing like MSVC, but you do not want to use windows only means to create GUI. Reasons for later requirement could be severe.

I am not an expert on Qt, but i think that I am experienced enought to be able to help younger students to get faster into the matter. I found out that the most of them have problems with installing and setting up an environment. The way to overcome such tough beginnings is the purpose of this walkthrough.

Why GUI?

We often work on school projects because we need credits :-) and we want to learn how to program. I think that one of basic knowledge of programmer is to write a code in C++. It is possible to write almost everything in C++. But some tasks might be little bit trickier. One of the fundamental things in C++ is ability to work with libraries. Pure C++ can not do too much. After you explore how to write algorithms, handle input and output, use data structures libraries you will come to need for a user interface.

Most people believe, that the program is the thing which they can see on their screens, nothing else. Decades ago I was the same (so i used IDEs like Delphi or C++Builder). In you prior studies you discover that it is definitely not true. But the majority of people expect from programmers, that they will write an user interface. If you are lucky and smart, you will newer write one. But in other cases you will need powerful (=easy) way to append user interface to your software project. By user interface I mean windows and buttons on your screen which are handled by your stand-alone application (not web interface written in HTML handled by web browser).

Why Qt?

Qt is multiplatform C++ (with interfaces to other languages) GUI library. There are also other possibilities, even easier, how to write the GUI application. But Qt is quite common and popular way to build stable, portable, nice-looking application. There are many reasons for this solution and also against it. From educational angle of view, by using Qt you will learn a lot of useful things and gain necessary experience which could be exploited in other projects.

I got an inspiration from http://ankanet.org/index.php/tools/getting-started-with-other-ides for this text. This step-by-step walkthrough was made 01/05/08. So it might not be up-to-date.

Lets start..

Application deployment.

Compiled and linked application depends on several Qt dynamic link libraries (DLLs). To run it on another computer you need to distribute it with all these DLLs. Try to send you demo application to your friends and test whether it is able to work on their computers.

Qt assistant.

Try Qt assistant assistant.exe in Qt subdirectory bin\. It is help browser similar to MSDN.

Qt designer.

Try Qt designer designer.exe in Qt subdirectory bin\. It is designer for complicated forms. In practice it is impossible to develop complicated design in code.

Qt designer generates .ui files which are XML describtion of the form design. There is an utility called uic in bin\ subdirectoty of Qt Directory which can generate .cpp and .h files implementing described design. Qmake tool call this utility for files writen in .pro file in variable FORMS. You can call it independently. It is the way how to get easily designed forms into the C++ code.

Qt demos.

Try Qt demos qtdemos.exe in Qt subdirectory bin\. It is presentation of features which Qt framework provide.

Qt tutorial.

Read a real official tutorial on http://doc.trolltech.com/4.3/tutorial.html


Last update: Thu May 1 20:17:18 CEST 2008