Qt C++ Development Guide
Why Learn Qt C++
Qt is a mature, open-source C++ UI framework with commercial support. It is especially well suited for industrial, medical, and other device-oriented software.
- Stability and maturity: Qt has a long production track record and a large ecosystem
- Cross-platform advantage: one source tree can build applications for Windows, macOS, and Linux
- Command-line support: Qt is not limited to GUI apps; it also works well for console tools
- Learning value: it has rich documentation, clear conventions, and practical examples that help deepen C++ skills
Development Environment
Installing Qt Libraries and Tools
- Use the Qt Online Installer
- On Linux, package managers such as
aptcan install the distribution-provided build - You can also build from source. The example below uses Linux:
# Install dependencies
sudo apt install -y build-essential libgl1-mesa-dev \
libfontconfig1-dev \
libfreetype6-dev \
libx11-dev \
libx11-xcb-dev \
libxext-dev \
libxfixes-dev \
libxi-dev \
libxrender-dev \
libxcb1-dev \
libxcb-cursor-dev \
libxcb-glx0-dev \
libxcb-keysyms1-dev \
libxcb-image0-dev \
libxcb-shm0-dev \
libxcb-icccm4-dev \
libxcb-sync-dev \
libxcb-xfixes0-dev \
libxcb-shape0-dev \
libxcb-randr0-dev \
libxcb-render-util0-dev \
libxcb-util-dev \
libxcb-xinerama0-dev \
libxcb-xkb-dev \
libxkbcommon-dev \
libxkbcommon-x11-dev \
libssl-dev libclang-dev libbluetooth-dev
# Configure
./configure -release -prefix /opt/qt/6.5 \
-no-accessibility -openssl-linked \
-disable-deprecated-up-to 0x060500 \
-skip qt3d \
-skip qt5compat \
-skip qtactiveqt \
-skip qtdatavis3d \
-skip qtdeclarative \
-skip qtdoc \
-skip qtlocation \
-skip qtlottie \
-skip qtmqtt \
-skip qtopcua \
-skip qtscxml \
-skip qtquick3d \
-skip qtquick3dphysics \
-skip qtquickeffectmaker \
-skip qtquicktimeline \
-skip qtwebengine \
-skip qtwebview \
-skip qtvirtualkeyboard \
-- -DOPENSSL_USE_STATIC_LIBS=ON
# Build and install
cmake --build . --parallel && sudo cmake --install .
cmake --build . --target docs && sudo cmake --build . --target install_docs
# Add Qt to PATH
echo 'export PATH="/opt/qt/6.5/bin:$PATH"' >> ~/.profile
Code Editing and Compilation
- Use Qt Creator or a common editor such as VSCode
- A minimal CMake setup looks like this:
cmake_minimum_required(VERSION 3.14)
project(test LANGUAGES CXX)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(Qt6 REQUIRED COMPONENTS Core)
link_libraries(Qt6::Core)
add_executable(test main.cpp)
main.cpp: