Diese Seite auf Deutsch lesen

C++ with Qt Programming Tutorial

Welcome to my C++ with Qt programming tutorial. During the following weeks and months, this tutorial will steadily grow step by step. You can access all parts of the tutorial from this index page.

This first programming tutorial covers the basics of the C++ programming language. It is mainly aimed at beginners, but hopefully will also provide some additional knowledge for more experienced programmers, especially those who are not yet accustomed to the C++ programming language.

Due to the focus on beginners, this tutorial includes a lot of additional background information that is also useful for other imperative programming languages to know if you are just starting out as a programmer.

The C++ programming language

Usually, if you want to teach someone computer programming, the commonly used programming languages are BASIC, Logo and others, but not C or C++.

I decided to go with C++ because of several benefits:

  • it is one of the most popular and commonly used programming languages (especially when it comes to professional software development)
  • its functionality allows a much broader usage for all kinds of programs/applications than most easier, beginner-specific programming languages
  • with knowledge about C++ programming, it is relatively easy to learn other programming languages like Java quite fast
  • it can be used on most any kind of platform
  • it supports object-oriented programming
  • I have a good deal of experience with it

While I have to admit that it is not the most beginner-friendly programming language, it is definitely worth the effort it takes to learn it.

The Qt library and SDK

In addition to the C++ programming language, I also chose to go with the "Qt" library and according software development kit (SDK) for this series of programming tutorial articles.

The Qt function and object library was originally developed by Nokia and is now maintained by Digia and the open source Qt development project. In addition to the library which can be used in C++ programming projects, the Qt download package also contains a complete integrated development environment with special integrated tools.

While basic C++ programming can be learned without the Qt library, sooner or later you want to add a modern user interface and support for enhanced features of the operating system to your programs. This can be done by using functionality from libraries which are specific for your operating system of choice.

But I did not want to exclude anyone from this tutorial by limiting things to just one operating system. Also, I did not want to write several (at least three) versions for any part of the tutorial.

With the Qt SDK, I can use advanced functionality in the programs of this tutorial which is platform-independent. There will still be differences in the look and feel of standard interface elements (window frames, resize elements, buttons etc.) between the different operating systems, but the code will be the same for all platforms (Windows, MacOS X and Linux).

At the moment, Qt is available for Windows, MacOS X and Linux. But mobile device support is already being worked on and there are a even a few prototypes using Qt on Android and iOS. The upcoming versions will feature support for both of these mobile operating systems, as Digia has recently officially stated. 

Learn C++ programming with Qt

So, enough for now - let's start with the actual programming tutorial teaching you how to program in the C++ programming language and using the Qt library.

Here is the overview of the currently available parts of the programming tutorial:

More details on the individual articles can be found below.

Introduction to the C++ and Qt development tools

In this first chapter of my tutorial on C++ programming with Qt you will first learn where you can get the necessary tools and how you can install them on your computer. This part is a bit lengthy, but you will only have to go through this once, so it's better to take your time and do it properly.

After the installation, you should take some additional time in order to get to know the Qt Creator application. This is the central part of the Qt software development kit. It acts as an integrated development environment where you write code, test your application, search and analyze errors and finally deploy it to your target platform as a stand-alone application. You will spend a lot of time here.

Introduction to C++ programming

With the development environment being set up and good to go, we start into proper C++ programming by creating a first, simple program. The program may not do much, but even so there is much to learn about it.

Take your time, read though the article and experiment for yourself.

After this first program, we take a closer look at some basic (but useful) output and input functions which provide a first way to interact with our programs (and thus with the computer). This is followed by further articles about the definition of variables using standard data types, constants, advanced data types etc. These are basic and important building blocks that you need for writing your own programs and which you should be careful to initialize properly.

Adding comments to your program helps a lot with making the program more readable for you and other programmers, as well as with optimizing the code.

With the additional knowledge about identifiers and reserved keywords that you need to avoid when you name your own variables, types, functions etc., several possible errors can be avoided up front.

After that, we add control structures. The first in line are if-then-else structures, which allow the implementation of a branching logical flow within a program.

A similar, but more expansive option are switch-case control structures. These allow for a "multiple split" in the program's logical flow and are useful, if you want to do different things depending on several different, but concrete input or computed values.

(...more to come...)

Final words

Computer programming is a broad topic, even when you look at it from the perspective of a single programming language. There is much to learn - and even as an experienced programmer, I can tell you that the learning never stops.

So stay tuned for the next parts of this programming tutorial...

Enjoy this page? Please pay it forward. Here's how...

Would you prefer to share this page with others by linking to it?

  1. Click on the HTML link code below.
  2. Copy and paste it, adding a note of your own, into your blog, a Web page, forums, a blog comment, your Facebook account, or anywhere that someone would find this page valuable.