The aim of this tutorial is to give programmers new to Qt application development a helping hand by showing how to develop an example full Qt application step by step. I will try to explain most lines of code and to give background information on how some of the design decisions are made.
As with most tutorials of this type, the pre-requisites are some knowledge of C++ and access to a system with QtCreator and Qt4 installed. QtCreator is a cross-platform Integrated Development Environment (IDE) to develop Qt projects written by Trolltech (now a part of Nokia). It is available for the Linux, Mac OS X and Microsoft Windows platforms.
The development environment I used for preparing this tutorial was OpenSUSE 11.1 that provided Qt 4.4. However I updated the system by installing QtCreator 1.2 and Qt 4.5 so you should find the tutorial works with most modern Linux distributions. This tutorial should also work on Microsoft Windows. If you haven't already please do read the QtCreator manual. If you are looking for my KDevelop tutorials, please go here.
Please, if you do have any suggestions for improvements or spot any mistakes, please email me.
The example application is to simulate packet radio networks with a graphical user interface, but please don't be concerned by this as it is the Qt programming techniques that are important in this tutorial rather than the application itself.
Part 1: Getting started
In this part we start the project in QtCreator and compile and run our first Qt application!
Part 2: Adding a menu bar and a status bar
Here we start to modify the template code generated by QtCreator to add a menubar and statusbar.
Part 3: Adding a display area
Now we add a Qt Graphics View central display widget to be used later to manage and interact with our application data.
Part 4: Enhancing the statusbar
Using the Qt signal and slot mechanism we enhance the statusbar to say where the user clicked on central display area.
Part 5: Drawing on the display area
Placing symbols on the central display widget to represent the radio stations in our simulation.
Part 6: Moving and deleting items
Allow the user to move and delete the radio stations in our simulation.
Part 7: Adding an undo stack
Here we will add an undo stack and undo stack view to our application.
Part 8: Implementing undo commands
Now we implement the undo & redo commands for adding, moving and deleting stations.
Part 9: Saving to a file
Saving our application data to an XML file.
Part 10: Loading from a file
And the ability to load from our XML files.
Part 11: Print and Print Preview
Here we will add the ability to print and print preview our simulated landscape.
Part 12: New and Quit
Here we will add two more file menu options and a toolbar.
Review of what we have done.
Hope you have found this tutorial useful. Please check back in the future as I plan to extend it when I get the time.
The Trolltech Qt whitepaper gives an excellent introduction to capabilities and scope of the Qt toolset. The Qt documentation is some of the best I have ever seen. Have a look at it whenever you wonder what a class does.