As part of the programming module you study on the course, you will be tasked with using the C++ programming language to complete lab activities and assessments. For the assessment, you will be required to implement a graphical user interface, and the framework of choice for this module is Qt.
In this guide, you shall be taken through the journey of installing the Qt framework for a Linux (Debian-based) operating system.
Before you can begin the process of downloading and installing the Qt framework, you will need to register for an account. To register for an account you will want to visit the following URL:
The account is free to register for, and you will be using the open-source version of the framework. There is a commercial/licensed product. However, you are not expected to pay for this.
When registering for your account, you will want to use your Coventry University e-mail address, and a password that you can remember. This password is crucial in the next step, during the installation process.
Once you have registered for an account, you can begin the process of downloading the installer file. To do this, you can visit the following link and it should begin the download process automatically:
The file should be downloaded to the Downloads
directory on your machine.
With the installer file download and present in the Download
directory, you now need to begin the process of
installation. To begin the installation process, you will want to locate the installer on your machine (in the
Downloads
directory), and double-click on the file to begin the process.
The initial screen of the window will ask for you to login to your Qt account. You will need to enter the details you used previously for the registration step, i.e. the e-mail address and password. Once you have entered your e-mail and password in the provided fields, click on the Next button.
On the next screen, you may be met with a warning, similar to the one below:
No valid commercial license available in your Qt Account for this host platform.
Please renew your license(s) from "https://login.qt.io/login". Alternatively, you can continue using old versions of Qt.
This is to be expected, and we shall proceed with the installation process, albeit using an older version of the framework. Therefore, click on the Next button to continue with the installation process.
The next screen will provide you an option to contribute towards the Qt development, i.e. sending bug reports etc. In this instance, we are not concerned with supplying the organisation with our details and therefore you will want to select the option labelled: Disable sending pseudonymous usage statistics in Qt Creator, and then click the Next button.
It is on the next page that things become interesting, and you will need to make a choice. For the programming module and assessment, you will be concerned with installing a Custom Installation, therefore, you will want to ensure you select this option and then click the Next button.
On the next screen, you will be met with a load of different options for installation. However, to simplify the selection, on the right-hand-side of the window, uncheck the Previous option and click on the Filter button. This will reduce the number of options you can select from.
In the scrollable section, you will see a few options labelled QT Design Studio, Extensions, Qt and Qt Creator.
Here, you will want to extend the option called Qt by selecting the >
next to the label Qt
. This will expand
the category to provide a list of options available for installation. You will want to ensure the option
MSVC 2022 64-bit
is selected, and the others are left blank. Then click on the Next button.
You will then be met with the obligatory terms and conditions, which students are encouraged to read and accept. Keep in mind that if you break these terms and conditions, the university will not be obligated to protect you.
Once you have read the terms and conditions and have accepted them, you can click on the Next button, followed by clicking on the Install button to begin the process of installing the framework to your machine. This process may take sometime. When the process has finished, you will be met with a final screen, and a few check box options. You can deselect the two options labelled Launch Qt Creator and Open Qt Design Studio README file, and then click on the Finish button.e
To confirm whether you have installed the Qt framework correctly, you can run the C++ script provided below. The
outcome of this script should display a label saying: "Hello CUEH!"
in a QApplication
window.
#include <QApplication>
#include <QLabel>
int main(int argc, char *argv[]) {
QApplication a(argc, argv);
QLabel label("Hello CUEH!", nullptr);
label.resize(200, 100);
label.show();
return QApplication::exec();
}
If you are using the JetBrains CLion IDE, you will need to modify the CMakeLists.txt
file so it looks like the one
below:
cmake_minimum_required(VERSION 3.29)
project(My_First_Project)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_PREFIX_PATH "C:/Qt/6.8.0/msvc2022_64")
find_package(Qt6 COMPONENTS Core Gui Widgets REQUIRED)
add_executable(My_First_Project main.cpp)
target_link_libraries(My_First_Project Qt::Core Qt::Gui Qt::Widgets)
if (WIN32 AND NOT DEFINED CMAKE_TOOLCHAIN_FILE)
set(DEBUG_SUFFIX)
if (MSVC AND CMAKE_BUILD_TYPE MATCHES "Debug")
set(DEBUG_SUFFIX "d")
endif ()
set(QT_INSTALL_PATH "${CMAKE_PREFIX_PATH}")
if (NOT EXISTS "${QT_INSTALL_PATH}/bin")
set(QT_INSTALL_PATH "${QT_INSTALL_PATH}/..")
if (NOT EXISTS "${QT_INSTALL_PATH}/bin")
set(QT_INSTALL_PATH "${QT_INSTALL_PATH}/..")
endif ()
endif ()
if (EXISTS "${QT_INSTALL_PATH}/plugins/platforms/qwindows${DEBUG_SUFFIX}.dll")
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory
"$<TARGET_FILE_DIR:${PROJECT_NAME}>/plugins/platforms/")
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
"${QT_INSTALL_PATH}/plugins/platforms/qwindows${DEBUG_SUFFIX}.dll"
"$<TARGET_FILE_DIR:${PROJECT_NAME}>/plugins/platforms/")
endif ()
foreach (QT_LIB Core Gui Widgets)
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
"${QT_INSTALL_PATH}/bin/Qt6${QT_LIB}${DEBUG_SUFFIX}.dll"
"$<TARGET_FILE_DIR:${PROJECT_NAME}>")
endforeach (QT_LIB)
endif ()
The differences compared to the normal CMakeLists.txt
file are the following lines:
set(CMAKE_PREFIX_PATH "C:/Qt/6.8.0/msvc2022_64")
: e sets the path C:/Qt/6.8.0/msvc2022_64
as the directory to
search for packages for the Qt framework during the build configuration processfind_package(Qt6 COMPONENTS Core Gui Widgets REQUIRED)
: finds and configures the Qt6 libraries (Core, Gui, and
Widgets), ensuring they are available and marking them as mandatory for the buildtarget_link_libraries(My_First_Project Qt::Core Qt::Gui Qt::Widgets)
: links the My_First_Project
target to the Qt
libraries Qt::Core
, Qt::Gui
, and Qt::Widgets
The stuff at the end of the CMakeLists.txt
beginning with if (WIN32 AND NOT DEFINED...
is required to ensure that
the Qt libraries are founded and loaded correctly when it comes to running your script/tool.
Hopefully, once you have compiled and built your script a graphical user interface should pop-up with a label saying:
Hello CUEH!
.
That is the end of this guide on installing the Qt framework. If you have followed all the necessary steps correctly, you should have a fully functional implementation of the OpenCV libraries, bespoke to your machine. This will enable you to complete any necessary programming based lab activities and assessments that you will participate with on this course.
If you have spotted any errors or issues within this tutorial, you can e-mail Dr Ian Cornelius. Ensure to include in your message a description of the error or issue and a possible resolution. Also remember to include a URL to the page with the issue or error.