GitHub - rcalixte/libqt6c-demo: Qt 6 demo for C (original) (raw)
Demo application using the MIT-licensed Qt 6 bindings for C
This demo application can be thought of as a simpler instructive template for using the main library than the examples. Please try out the demo application and start a discussion if you have any questions or issues relevant to this demo application.
TABLE OF CONTENTS
License
The demo application within libqt6c-demo is licensed under the MIT license.
Building
FreeBSD (native)
sudo pkg install qt6-base
Note
The zig package will need to be downloaded and installed separately if the latest stable version is not available in the default repositories.
Linux (native)
Debian-based distributions
sudo apt install gcc libstdc++-14-dev-$(dpkg --print-architecture)-cross qt6-base-dev
Note
The zig package must be downloaded and installed separately.
Fedora-based distributions
sudo dnf install sysroot-$(uname -m)-fc$(lsb_release -rs)-glibc gcc libstdc++-devel qt6-qtbase-devel
Note
The zig package will need to be downloaded and installed separately if the latest stable version is not available in the default repositories.
Arch-based distributions
sudo pacman -S gcc qt6-base
Users of Arch-based distributions need to make sure that all packages are up-to-date and then run the following commands:
sudo mkdir -v /usr/$(uname -m)-pc-linux-gnu && sudo cp -pr /usr/include /usr/$(uname -m)-pc-linux-gnu/
Note
The zig package will need to be downloaded and installed separately if the latest stable version is not available in the default repositories.
openSUSE-based distributions
sudo zypper install qt6-base-devel
Users of openSUSE-based distributions need to make sure that all packages are up-to-date and then run the following commands:
sudo cp -pr /usr/include/* /usr/$(uname -m)-suse-linux/include/
Note
The zig package will need to be downloaded and installed separately as the version in the default repositories is too unstable for usage.
macOS (native)
To install the Qt 6 dependency using Homebrew:
Important
In recent versions of Qt 6, the symlinks are not correctly created at the time of installation and must be created manually for each framework. For the demo application, the following commands can be used to create the symlinks:
ln -s /opt/homebrew/lib/QtCore.framework/Headers /opt/homebrew/include/QtCore ln -s /opt/homebrew/lib/QtGui.framework/Headers /opt/homebrew/include/QtGui ln -s /opt/homebrew/lib/QtWidgets.framework/Headers /opt/homebrew/include/QtWidgets
The official Qt installer is also supported but will require manually creating the symlinks as above and using the extra-paths option described below, using the root of the include directory as the path value.
Note
The zig package will need to be downloaded and installed separately if the latest stable version is not available via Homebrew.
Windows (native)
For Windows, use the official Qt installer and install a Qt version built with LLVM-MinGW.
Note
The zig package will need to be downloaded and installed separately.
Once the required packages are installed, the demo application can be built from the root of the repository:
To build and run the demo application:
In the event that another system library path is needed e.g. a different Qt installation path, the extra-paths option supports this use case:
zig build -Dextra-paths="C:/Qt/6/llvm-mingw_64"
or
zig build -Dextra-paths={"/opt/qt6","/opt/lib/qt6"}
For Windows hosts, there is an additional option to specify the Qt installation directory. This is only required if passing in an alternate extra library path meant to override the default Qt library path:
zig build -Dextra-paths="C:/Qt/6/llvm-mingw_64" -DQTDIR="C:/Qt/6/llvm-mingw_64"
The demo application can be installed to the system in a non-default location by adding the --prefix-exe-dir option to the build command:
sudo zig build --prefix-exe-dir /usr/local/bin # creates /usr/local/bin/mdoutliner
The source code for the demo application can be found in the src directory of the repository.
Screenshots
![]() |
|---|
| CachyOS + KDE |
![]() |
| Fedora + KDE |
![]() |
| FreeBSD + Xfce |
![]() |
| Linux Mint + Cinnamon |
![]() |
| macOS |
![]() |
| Windows |
FAQ
Q1. How long does it take to compile the demo application?
The first compilation should take less than a minute, far less on more recent or capable hardware.
Q2. What build modes are supported by the build system used by the demo application?
Currently, Debug, ReleaseFast, ReleaseSafe, and ReleaseSmall are supported. This may change in the future. The default build mode is Debug. To change the build mode:
zig build -Doptimize=ReleaseSmall
or
zig build --release=small
Q3. Can I use another build system to compile the demo application?
Assuming the main library has been properly compiled and the include directory of headers is available, the demo application can be built with any build system that supports C. A sample compilation using gcc run from the root of the repository on a Linux machine:
gcc src/mdoutliner/main.c -o mdoutliner -march=native -I/path/to/libqtc/include -L/path/to/libqtc/compiled/lib -lqaction -lqapplication -lqboxlayout -lqcoreapplication -lqfiledialog -lqguiapplication -lqicon -lqkeysequence -lqlayout -lqlayoutitem -lqlistwidget -lqlocale -lqmainwindow -lqmenu -lqmenubar -lqobject -lqpaintdevice -lqresource -lqsplitter -lqtabwidget -lqtextcursor -lqtextdocument -lqtextedit -lqtextobject -lqtranslator -lqvariant -lqwidget -lqframe -lqabstractscrollarea -lqdialog -lqabstractitemview -lqlistview -lQt6Widgets -lQt6Core -lQt6Gui -lstdc++
This should produce a binary executable named mdoutliner that can be run from the command line. The compilation process should complete without any errors or warnings being displayed while taking less than a few seconds to complete.
Special Thanks
- @mappu for the MIQT bindings that provided the phenomenal foundation for this project
- @arnetheduck for proving the value of collaboration on the back-end of the library while working across different target languages





