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.
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:The opening window does not show system files starting with a dot. You can see them by adding a cross at ”Show hidden files”:
After that you can see the content of
.config
directory and you can remove all the files insideQtProject
directory (which is inside the first-mentioned directory).Start Qt Creator tool from
Applications > Programming > Qt Creator
:when you can see the starting window of Qt Creator:
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 tabFile Naming
. Check that file suffix for Headers ishh
and that for Sources iscpp
(orcc
):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.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 underOpen Project
orRecent Projects
directly with mouse. However, we assume here that you are starting a new project, and thus, you can chooseNew 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.
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 asPlain C++ Application
:After that select
Choose...
from the bottom right.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 exampleweekly_exercise-01-task-03
andproject_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 clickingBrowse
inProject Location
window and then, in the top right corner of the opening window, clickingCreate Folder
, after navigating in the desirable directory.After the selections described above, the situation should, more or less, be like:
Choose now
Next>
from bottom right.Everything in windows
Build System
andKits
should be ok, and it is sufficient to selectNext>
from bottom right.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>
atAdd to version control
. Finally, pressFinish
.
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.
Download the Qt online installer from here. The site should automatically offer you the right installer, depending on your operating system.
Run the Qt installer.
Create a Qt account and log in by clicking next. Proceed with the installation as you prefer, for example, as follows.
Finally, you should encounter the following window. Select Custom installation.
In the component selection window, select Latest releases. Close the Preview and Additional libraries drop menus. Open the Qt drop menu.
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).
Under Developer and Designer Tools, select the MinGW 8.1.0 64-bit component.
Proceed with the installation. This might take a long time (up to hours), but the installation should complete regardless.
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.