Qt

Related articles
KDE
Uniform look for Qt and GTK applications
GTK
Qt
is a cross-platform application and widget toolkit that uses standard C++ but makes extensive use of a special code generator (called the
Meta Object Compiler
, or
moc
) together with several macros to enrich the language. Some of its more important features include:
Running on the major desktop platforms and some of the mobile platforms.
Extensive internationalization support.
A complete library that provides SQL database access, XML parsing, thread management, network support, and a unified cross-platform application programming interface (API) for file handling.
The Qt framework is the basis of the
KDE
software community, as well as other important open source and proprietary applications such as
VLC
,
VirtualBox
,
Mathematica
and many others.
Installation
Note
Qt versions before 5 have reached end of life and are unmaintained.
Qt 6.x and 5.x are available in the
official repositories
. Legacy versions of Qt (4.x and 3.x) are available from the
AUR
. They can be
installed
with the following packages:
Qt 6.x
is available in the
qt6-base
package, with documentation in the
qt6-doc
package.
Qt 5.x
is available in the
qt5-base
package, with documentation in the
qt5-doc
AUR
package.
Qt 4.x
is available in the
qt4
AUR
package, with documentation in the
qt4-doc
AUR
package.
Qt 3.x
is available in the
qt3
AUR
package, without documentation package.
Default Qt toolkit
To define the default Qt toolkit, you can create the
QT_SELECT
environment variable
. For example, to use Qt
n
, set
QT_SELECT=
n
.
Configuration
This article or section is out of date.
Reason:
need an update for qt6 (Discuss in
Talk:Qt
)
Styles in Qt 5
This article or section is out of date.
Reason:
qt5-base
no longer uses QGtkStyle (Discuss in
Talk:Qt#Qt5 no longer uses QGtkStyle
)
Qt 5 decides the style to use based on what desktop environment is used:
In KDE Plasma, it uses the actually selected Qt style. It can be configured using
KDE System Settings
(
systemsettings
), the settings can be found in
Appearance > Application Style > Widget Style
.
In Cinnamon, GNOME, MATE, LXDE, Xfce, it uses GTK (
QGtkStyle
).
In other desktop environments, it uses Fusion.
To force a specific style, you can set the
QT_STYLE_OVERRIDE
environment variable
. Specifically, set it to
gtk2
if you want to use the
GTK
theme (Note: you will need to install the Qt style plugins mentioned below to get the GTK style). Qt 5 applications also support the
-style
flag, which you can use to launch a Qt 5 application with a specific style.
The following styles are included in Qt 5:
Fusion
,
Windows
. Others can be installed separately:
Breeze
— Artwork, styles and assets for the Breeze visual style for the Plasma Desktop.
https://invent.kde.org/plasma/breeze
||
breeze
Oxygen
— KDE Oxygen style.
https://invent.kde.org/plasma/oxygen
||
oxygen
Darkly
— Darkly is a modern fork of the obsolete Lightly, a Breeze theme style that aims to be visually modern and minimalistic.
https://github.com/Bali10050/darkly
||
darkly
AUR
QtCurve
— A configurable set of widget styles for KDE and Gtk.
https://invent.kde.org/system/qtcurve
||
qtcurve
AUR
Adwaita-Qt
— A style to bend Qt applications to look like they belong into GNOME Shell.
https://github.com/MartinBriza/adwaita-qt
||
adwaita-qt5-git
AUR
Qt style plugins
— Additional style plugins for Qt 5, including
GTK
,
Cleanlooks
,
Motif
,
Plastique
.
https://code.qt.io/cgit/qt/qtstyleplugins.git
||
qt5-styleplugins
AUR
Kvantum
— customizable SVG-based theme engine with a variety of built-in styles, including imitations of some popular GTK themes such as
Adapta
,
Arc
,
Ambiance
https://github.com/tsujan/Kvantum/tree/master/Kvantum
||
kvantum
Qt Style Sheets
An interesting way of customizing the look and feel of a Qt application is using Style Sheets, which are just simple CSS files. Using Style Sheets, one can modify the appearance of every widget in the application.
To run an application with a different style just execute:
$
qt_application
-stylesheet
style.qss
For more information on Qt Style Sheets see the
official documentation
or other
tutorials
. As an example Style Sheet see this
Dolphin modification
.
GTK and Qt
If you have GTK and Qt applications, their looks might not exactly blend in very well. If you wish to make your GTK styles match your Qt styles please read
Uniform look for Qt and GTK applications
.
Configuration of Qt 5/6 applications under environments other than KDE Plasma
Unlike Qt 4, Qt 5 does not ship a qtconfig utility to configure fonts, icons or styles. Instead, it will try to use the settings from the running desktop environment. In KDE Plasma or GNOME this works well, but in other less popular desktop environments or window managers it can lead to missing icons in Qt 5 applications. One way to solve this is to fake the running desktop environment by setting
XDG_CURRENT_DESKTOP=KDE
or
GNOME
, and then using the corresponding configuration application to set the desired icon set.
Another solution is provided by the
qt5ct
/
qt6ct
packages, which provide a
QPA
independent of the desktop environment and a configuration utility. After installing package, run
qt5ct
/
qt6ct
to set an icon theme, and set the
environment variable
QT_QPA_PLATFORMTHEME=qt5ct:qt6ct
so that the settings are picked up by Qt applications. Alternatively, use
--platformtheme qt5ct
as argument to the Qt 5 application.
qt5ct-kde
AUR
and
qt6ct-kde
AUR
provide patched
qt5ct
/
qt6ct
with better integration to KDE applications, including KDE QML applications and can read and apply KColorSchemes.
If the errors below are received, and some icons still do not appear in some of the applications, install
oxygen
and
oxygen-icons
:
Icon theme "oxygen" not found.
Icon theme "oxygen" not found.
Error: standard icon theme "oxygen" not found!
Development
Supported platforms
Qt supports most platforms that are available today, even some of the more obscure ones, with more ports appearing every once in a while. For a more complete list see the
Qt Wikipedia article
.
Android
Note
Qt Creator 4.12 or later can set up the SDK Tools, NDK, and essential packages automatically. For more information, see
Qt Creator: Specifying Android Device Settings
First of all, you need an
Android SDK
and NDK from
AUR
or using
Android Studio
.
SDK requires
OpenJDK
too. Different Qt versions have different version requirements, check
here
for detail.
Next you are going to need Qt 5 for Android. You can install it from
AUR
as described below or build it yourself, you can find build instructions on Qt
wiki
page.
In case of problems you may want to visit
known issues
.
This article or section is out of date.
Reason:
The following AUR packages ceased to build and were removed by the maintainer. A
suggested alternative
are QT6 packages. (Discuss in
Talk:Qt
)
android-armv7a-eabi-qt5
AUR
[
broken link
: package not found]
- armeabi-v7a
android-aarch64-qt5
AUR
[
broken link
: package not found]
- aarch64
android-x86-qt5
AUR
[
broken link
: package not found]
- x86
android-x86-64-qt5
AUR
[
broken link
: package not found]
- x86_64
Alternatively, you can use the
official Qt installer
.
Tools
The following are official Qt tools:
Qt Creator
— A cross-platform IDE tailored for Qt that supports all of its features.
https://doc.qt.io/qtcreator/
||
qtcreator
Note
Install the relevant
optional dependencies
for using other tools from Qt Creator, such as a debugger or version control.
Qt Linguist
— A set of tools that speed the translation and internationalization of Qt applications.
https://doc.qt.io/qt-6/qtlinguist-index.html
|| Qt 6:
qt6-tools
, Qt 5:
qt5-tools
, Qt 4:
qt4
AUR
Qt Assistant
— A configurable and redistributable documentation reader for Qt
qch
files.
https://doc.qt.io/qt-6/qtassistant-index.html
|| Qt 6:
qt6-tools
, Qt 5:
qt5-tools
, Qt 4:
qt4
AUR
Qt Widgets Designer
— A powerful cross-platform GUI layout and forms builder for Qt widgets.
https://doc.qt.io/qt-6/qtdesigner-manual.html
|| Qt 6:
qt6-tools
, Qt 5:
qt5-tools
, Qt 4:
qt4
AUR
Qt Quick Designer
— A visual editor for QML files which supports WYSIWYG. It allows you to rapidly design and build Qt Quick applications and components from scratch.
https://doc.qt.io/qtcreator/creator-qtquickdesigner-plugin.html
||
qtcreator
qmlscene
— A tool for loading QML documents that makes it easy to quickly develop and debug QML applications.
https://doc.qt.io/qt-5/qtquick-qmlscene.html
|| Qt 6:
qt6-declarative
, Qt 5:
qt5-declarative
, Qt 4 QML Viewer:
qt4
AUR
qmake
— A tool that helps simplify the build process for development project across different platforms, similar to
cmake
, but with fewer options and tailored for Qt applications.
https://doc.qt.io/qt-6/qmake-manual.html
|| Qt 6:
qt6-base
, Qt 5:
qt5-base
, Qt 4:
qt4
AUR
uic
— A tool that reads
*.ui
XML files and generates the corresponding C++ files.
https://doc.qt.io/qt-6/uic.html
|| Qt 6:
qt6-base
, Qt 5:
qt5-base
, Qt 4:
qt4
AUR
rcc
— A tool that is used to embed resources (such as pictures) into a Qt application during the build process. It works by generating a C++ source file containing data specified in a Qt resource (.qrc) file.
https://doc.qt.io/qt-6/rcc.html
|| Qt 6:
qt6-base
, Qt 5:
qt5-base
, Qt 4:
qt4
AUR
moc
— A tool that handles Qt's C++ extensions (the signals and slots mechanism, the run-time type information, and the dynamic property system, etc.).
https://doc.qt.io/qt-6/moc.html
|| Qt 6:
qt6-base
, Qt 5:
qt5-base
, Qt 4:
qt4
AUR
Troubleshooting
Disable/Change Qt journal logging behaviour
When using
KDE
and/or any other Qt
desktop environment
debug info may be frequently logged in the
systemd journal
.
Set
QT_LOGGING_RULES
as
environment variable
to change this behaviour, e.g. to completely disable logging:
/etc/environment
QT_LOGGING_RULES='*=false'
To disable only debug logging, use
QT_LOGGING_RULES="*.debug=false"
.
Icon theme is not applied
Since Qt 5.1 SVG support has moved into a module. Since
qt5-base
does not depend on
qt5-svg
it may happen that the
qt5-base
is installed but not
qt5-svg
. This results in deceptive icon theme behaviour. Since SVG is not supported the icons are silently skipped and the icon theme may seem to be unused. Installing
qt5-svg
solves the problem.
Theme not applied to root applications
As the user theme file (
$XDG_CONFIG_HOME/Trolltech.conf
), are not read by other accounts, the selected theme will not apply to
X applications run as root
. Possible solutions include:
Create symlinks, e.g
# ln -s /home/[username]/.config/Trolltech.conf /etc/xdg/Trolltech.conf
Configure system-wide theme file:
/etc/xdg/Trolltech.conf
Adjust the theme as root
Qt 4 style not respected
If pure Qt 4 (non-KDE) applications do not stick with your selected Qt 4 style, then you will probably need to tell Qt 4 how to find KDE's styles (Oxygen, Phase etc.). You just need to set the
environment variable
QT_PLUGIN_PATH
. E.g.:
QT_PLUGIN_PATH=$HOME/.kde4/lib/kde4/plugins/:/usr/lib/kde4/plugins/
qtconfig-qt4
should then be able to find your kde styles and everything should look nice again!
Alternatively, you can symlink the Qt 4 styles directory to the KDE4 styles one:
# ln -s /usr/lib/{kde,qt}4/plugins/styles/
theme_name
All Qt 5-based applications fail to run after Qt 5 update
If you get an error similar to
Qt FATAL: Cannot mix incompatible Qt library (version 0x50900) with this library (version 0x50901)
then you are most likely using a Qt 5 platform theme or style plugin which has not been recompiled against the latest version of Qt 5. These usually use Qt private headers which means they depend on an exact version of Qt and not just a matching soname. Figure out which theme/style you are using by checking the
QT_STYLE_OVERRIDE
and
QT_QPA_PLATFORMTHEME
environment variables, and rebuild the AUR package that provides it.
QXcbConnection: XCB error: 2 (BadValue)
Create a file with such content
[1]
:
/etc/xdg/QtProject/qtlogging.ini
[Rules]
qt.qpa.xcb.xcberror=false
Graphics misaligned or scaled improperly
See
HiDPI#Qt 5
.
Dead keys not working for Qt apps
If you have set the right
keyboard configuration
and dead keys are working in
GTK
apps (or other
widget toolkits
) but not in
KDE
or any
Qt
apps, then you might not have the proper compose file loaded in your
Xorg
session.
A way to confirm that is to:
launch a Qt app with
qt.xkb.compose.debug
logging rule enabled, eg. launching
qtqr
AUR
:
QT_LOGGING_RULES=qt.xkb.compose.debug=true qtqr
then try to write a character using a dead key, eg.
<dead_circumflex> <e>
for
ê
(LATIN SMALL LETTER E WITH CIRCUMFLEX)
if you encounter
qt.xkb.compose: failed to create compose table
then you probably have this issue.
To fix this, first identify your
locale
. Then, if your locale doesn't have its own folder in
/usr/share/X11/locale/
, eg.
fr_FR.UTF-8
, look for it in the
compose.dir
mapping file to find the corresponding compose file (eg.
en_US.UTF-8/Compose
):
$ grep fr_FR.UTF-8 /usr/share/X11/locale/compose.dir
en_US.UTF-8/Compose             fr_FR.UTF-8
en_US.UTF-8/Compose:            fr_FR.UTF-8
Now create or edit
~/.XCompose
to include this compose file:
~/.XCompose
include "%S/en_US.UTF-8/Compose"
Finally, restart your
Qt
app, dead keys should be working and
qt.xkb.compose: failed to create compose table
error should have disappeared whenever you debug with
QT_LOGGING_RULES=qt.xkb.compose.debug=true
.
File dialog are very slow and crash the related application
The
~/.config/QtProject.conf
file has been filled with garbage data and weighs hundreds of MiB: remove it.
[2]
[3]
Qt 6.7 under Wayland sometimes ignore input method
Qt introduced text-input-v3 for Wayland platform. However, the implementation is not perfect and may cause serious issues preventing the usage of input method.
Set the following environment variable globally if your Wayland compositor supports text-input-v2:
/etc/environment
QT_WAYLAND_TEXT_INPUT_PROTOCOL=zwp_text_input_v2
Emojis render as black and white despite a color emoji font being installed
This article or section is being considered for removal.
Reason:
Duplicates
Fonts#Emoji and symbols
. (Discuss in
Talk:Qt
)
Qt does not support automatically looking up the best font for emojis, and therefore the user must manually add a color emoji font as a fallback.
[4]
To do this, save the contents of
this gist
to
/etc/fonts/conf.d/75-noto-color-emoji.conf
. This adds
noto-fonts-emoji
as a fallback, though "Noto Color Emoji" can be replaced with a different font family if the user desires.
Afterwards, relaunch the Qt applications affected to load the new font settings.
Crash or wrong scaling under Wayland
Some Qt apps, like
keepassxc
, crash
[5]
or suffer scaling issues
[6]
on
Wayland
.
To fix that, install
qt5-wayland
as explained in
Wayland#Qt
.
KDE Global Menu not working
Some Qt 5 applications like
keepassxc
, fails to use the Global Menu of
KDE
[7]
.
To fix it, install
plasma5-integration
as explained in
KDE#Plasma 6 Global Menu not working with some applications
.
Qt 6 applications should not pose a problem since
plasma-integration
is pulled by
plasma-workspace
.
See also
Official Website
Qt Documentation
Planet Qt