Qt

How to get up and running using Qt on Linux.

Environment

Kali Linux

Operating System

Windows 10 WSL1

Update

sudo -s
apt update
apt full-upgrade
apt autoremove

Install

Qt5

Creator

apt install qtcreator

Base

apt install qtbase5-dev

Serial

apt install qt5serialport-examples libqt5serialport5-dev

Strip

Due to a problem with WSL1 the Qt5 core library file needs to be stripped.

strip --remove-section=.note.ABI-tag /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
Qt6

Base

apt install qt6-base-dev

Strip

strip --remove-section=.note.ABI-tag /usr/lib/x86_64-linux-gnu/libQt6Core.so.6

Demo

QT Creator is used to create project files and edit source code.

qtcreator

Follow this guide to create a simple project.

Create Project...
  Application (Qt)
    Qt Console Application
      Name: QApp
      Build system: qmake
      Language: <none>
      Kit Selection: Desktop

main.cpp

This is clearly not a good example of a Qt application, but this code is just a demo.

#include <QCoreApplication>
#include <iostream>

int
main(int argc, char **argv)
{
        QCoreApplication App(argc, argv);

        std::cout << "Hello World!" << std::endl;

        return 0;
}

Qt5 make is used to create a working `Makefile' which is used to build the application.

qmake
make
./QApp
Hello World!

To build for Qt6, use qmake6 instead of qmake above.

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies