Example applications using the MIT-licensed Qt 6 bindings for C
These examples can be thought of as instructive templates for using the main library. Though some of the examples have some complexity to them, the intention is to aim for simplicity while demonstrating valid uses of the library. All of source code for the examples are a single file by design. Any auxiliary files are placed in the same directory for either compilation or execution purposes. Please try out the sample applications and start a discussion if you have any questions or issues relevant to these examples.
The sample applications within libqt6c-examples
are licensed under the MIT license.
The dependencies for building the sample applications are the same as the main library. Refer to the main library's Building section for more information.
It is recommended to execute an initial build to generate a clean build cache before making any changes. This allows the build process to use the cached build artifacts to speed up subsequent builds.
Once the required packages are installed, the library can be built from the root of the repository:
zig build
Users of Arch-based distributions need to make sure that all packages are up-to-date first and will need to add the following option to support successful compilation:
zig build -Denable-workaround=true
To skip the restricted extras:
zig build -Dskip-restricted=true
Example applications can also be built and run independently:
zig build helloworld events
Applications 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/{examples}
To see the full list of examples available:
zig build -l
To see the full list of examples and build options available:
zig build --help
The source code for the examples can be found in the src
directory of the repository.
The examples compile the main library and then build the sample applications from the source code. The first compilation should take less than 10 minutes, assuming the hardware in use is at or above the level of that of a consumer-grade mid-tier machine released in the past decade. Once the build cache is warmed up for the examples, subsequent compilations should be very fast, on the order of seconds.
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=ReleaseSafe
Assuming the main library has been properly compiled and the include
directory of headers is available, the examples can be built with any build system that supports C. A sample compilation of the helloworld
example using gcc
run from the root of the repository on a Linux machine:
gcc src/helloworld/main.c -o helloworld -march=native -I/path/to/libqtc/include -L/path/to/libqtc/compiled/lib -lqapplication -lqpushbutton -lqwidget -lqabstractbutton -lqobject -lqcoreevent -lqpaintdevice -lqcoreapplication -lqguiapplication -lQt6Widgets -lQt6Core -lQt6Gui -lstdc++
This should produce a binary executable named helloworld
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.
Several options are available to implement translations ranging from functions available in the main library to well-supported systems such as GNU gettext to Qt's internationalization options. Developers are free to use any of the available options or implement their own solution.
![]() |
![]() |
---|---|
Debian + Cinnamon + Qt 6.7 (custom theme) | EndeavourOS + KDE + Qt 6.8 |
![]() |
![]() |
Fedora + KDE + Qt 6.8 | FreeBSD + Xfce + Qt 6.8 |
![]() |
![]() |
Linux Mint + Cinnamon + Qt 6.4 | Ubuntu + Qt 6.4 |
-
@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