Qt Creator programming environment

This section briefly shows you the most essential phases to start working with Qt Creator programming environment. You will learn how to write and execute a simple program in the virtual desktop environment used on the course.

We assume that you have created a connection to the virtual desktop by following the guidance given in the previous section of the course material.

At the end of this section you can read how to install Qt Creator on your own computer.

General issues on Qt Creator

The programs in Qt Creator are projects, and thus, they always include a file with .pro suffix. This file tells which source code files the program has. (As simplest, a program has only one source code file, main.cpp, besides the project file.)

When storing programs into version control and submitting them in Plussa, make sure that there is also the .pro file along.

How to use Qt Creator on virtual desktop

Follow the steps below when you are starting to write a new program with Qt Creator. Note that steps 1 and 3 are initial ones that are needed to be done only once before writing the first program.

  1. If you have earlier attended a course, where you have used Qt Creator, you would be better to remove the old settings. If there have been any maintainaining actions on C++ or Qt Creator after your last use of them, it is possible that Qt Creator do not work.

    So, if you are using Qt Creator from the remote desktop for the first time, this step does not concern you. You can move directly to step 2!

    During this step, Qt Creator must not be running. Otherwise the old settings will stay.

    Remove the old settings by removing all files in directory ~/.config/QtProject. Start file management:

    ../../_images/filemanager.png

    The opening window does not show system files starting with a dot. You can see them by adding a cross at ”Show hidden files”:

    ../../_images/filemanager-hidden-files.png

    After that you can see the content of .config directory and you can remove all the files inside QtProject directory (which is inside the first-mentioned directory).

  2. Start Qt Creator tool from Applications > Programming > Qt Creator:

    ../../_images/qt-kaynnistys.png

    when you can see the starting window of Qt Creator:

    ../../_images/qt-aloitusikkuna.png
  3. From the top bar menu, choose Tools > Options..., where you can adjust the settings of Qt Creator. We may return to these setting later as the course advances, but already in this phase you can set the naming conventions of source code files.

    From {} C++, choose tab File Naming. Check that file suffix for Headers is hh and that for Sources is cpp (or cc):

    ../../_images/qt-suffixit.png

    Choose OK from bottom right, and you will return to the starting window of Qt Cretor and everything should be ready for the first programming project.

  4. You can start a new programming project by clicking mouse at New Project in the starting window of Qt Creator. If you have already started to write a program and you are continuing it after a break, you can choose the desirable project under Open Project or Recent Projects directly with mouse. However, we assume here that you are starting a new project, and thus, you can choose New Project.

    After that you will see a couple of windows, where Qt Creator asks some details concerning the project before letting you to write program code.

  5. The first thing to decide is the type of the project. In the beginning part of the course, all the programs are basic C++ programs without graphical interfaces or other specific features. Therefore, choose first the type of the project as Non-Qt Project and the subtype as Plain C++ Application:

    ../../_images/qt-new-project-ikkuna.png

    After that select Choose... from the bottom right.

  6. Next selection concerns the directory, where Qt Creator will store all the files of the project.

    At Name: write a name describing you project as well as possible. For example weekly_exercise-01-task-03  and  project_work-01 are good names for the project.

    Next you need to decide the directory, where you store the project. For this first task you, you can make the decision by yourself. It can be a good idea to create a directory called prog2 for the course. This can be done in file system management of the virtual desktop or by clicking Browse in Project Location window and then, in the top right corner of the opening window, clicking Create Folder, after navigating in the desirable directory.

    After the selections described above, the situation should, more or less, be like:

    ../../_images/qt-projektin-sijainti.png

    Choose now Next> from bottom right.

  7. Everything in windows Build System and Kits should be ok, and it is sufficient to select Next> from bottom right.

  8. The last step before actual programming concerns Project Management window. Here you can choose a version control system for your project. Although we will use Git version control on the course, we will not yet do so for this first project. Therefore, at this time choose <None> at Add to version control. Finally, press Finish.

On installing Qt Creator to your own computer

It is possible to install Qt Creator to your computer, when you can write programs without internet connection. Installation process depends on the operating system of your computer.

Note still that probably this is not exactly the same version of Qt Creator and C++ compiler as has been installed in remote desktop. So, there can be differences. We recommend you to do the course assignments on remote desktop, as long as possible. Install Qt on your own computer only if you can really maintain your computer by yourself or you have very serious trouble in network connections.

It is a good idea to test the assignments on the remote desktop before submitting them, since they will be tested in the same Linux environment by the course personnel. This is important, because it is possible that a program does not work in the same/correct way in different operating systems or in different versions of them.

Installation instructions

The instructions below are valid especially for Windows, but from the link given in the first step you start, even if you have another operating system.

To install Qt Creator to your own computer follow the steps below.

  1. Download the Qt online installer from here. The site should automatically offer you the right installer, depending on your operating system.

  2. Run the Qt installer.

  3. Create a Qt account and log in by clicking next. Proceed with the installation as you prefer, for example, as follows.

    ../../_images/qt_install_1.png
    ../../_images/qt_install_3.png
    ../../_images/qt_install_4.png
    ../../_images/qt_install_5.png
  4. Finally, you should encounter the following window. Select Custom installation.

    ../../_images/qt_install_6.png
  5. In the component selection window, select Latest releases. Close the Preview and Additional libraries drop menus. Open the Qt drop menu.

    ../../_images/qt_install_7.png
  6. Under Qt 5.15.2, select at least the MinGW 8.1.0 64-bit component. (In the figure, Qt Charts component has been selected as well, but it is not necessary).

    ../../_images/qt_install_8.png
  7. Under Developer and Designer Tools, select the MinGW 8.1.0 64-bit component.

    ../../_images/qt_install_9.png
  8. Proceed with the installation. This might take a long time (up to hours), but the installation should complete regardless.

  9. When the installation is ready, you may run Qt Creator to verify that the installation was successful. The window should look something like the following.

    ../../_images/qt_install_10.png