Alberto Marnetto's Notebook
Applications made with Qt are quite common on Linux and also often seen in Windows. One interesting thing about them is that they often support a series of parameters that allow to style their appearance and change other aspects. This information is not easily discoverable, being buried in the depths of Qt’s documentation and usually not appearing in the integrated manual page of the applications.
I am indebted to this gist by developer Paul Colby and its pointers into Qt’s documentation ([1][2][3]).
In bold the most useful parameters, according to my arbitrary judgment (i.e., those I have used in the last few months).
Parameter | Environment Variable | Effect |
---|---|---|
-dpi |
QT_SCREEN_SCALE_FACTORS |
Sets the DPI scaling factor for the application. QT_AUTO_SCREEN_SCALE_FACTOR also possible. |
N/A |
QT_QPA_FONTDIR |
Specifies the directory to look for additional fonts for the application. |
-geometry |
QT_WINDOW_GEOMETRY |
Specifies the window’s geometry (size and position). |
-graphicssystem |
QT_GRAPHICSSYSTEM |
Specifies the graphics system used (e.g., opengl , native ). |
-inputmethod |
QT_IM_MODULE |
Specifies the input method module to use (e.g., ibus , fcitx , qt ). |
N/A |
QT_LOGGING_RULES |
Defines the logging rules for various parts of Qt (e.g., qt.qpa.*=true for more verbose logging of the Qt platform). |
-platform |
QT_QPA_PLATFORM |
Specifies the platform plugin to use (e.g., xcb , wayland , windows ). |
-platformpluginpath |
QT_QPA_PLATFORM_PLUGIN_PATH |
Specifies the path to the platform plugin directory. |
-platformtheme |
QT_QPA_PLATFORMTHEME |
Specifies the platform theme (e.g., gtk2 , fusion ). |
-plugin |
QT_QPA_GENERIC_PLUGINS |
Additinal plugin to load. Can be used multiple times. |
-qml |
QT_QML_IMPORT_PATH |
Starts the application with a QML file or specifies additional QML import paths. |
-qwindowgeometry |
Sets the window geometry in format -qwindowgeometry 600x600+250+50 . |
|
-qwindowtitle |
Sets the title of the main window. | |
-reverse |
Renders the application as if it were in a right-to-left locale. | |
-scaleFactor |
QT_SCALE_FACTOR |
Specifies the overall scale factor for the application UI. |
-session |
Restores an application from an earlier session. | |
-style |
QT_STYLE_OVERRIDE |
Overrides the default style used by the Qt application (e.g., Fusion , Windows ). |
-stylesheet |
Applies a custom .qss stylesheet to the application. | |
-stylesheetpath |
QT_STYLESHEET_PATH |
Specifies a path to a default stylesheet file to load. |
-version |
Displays the Qt version used by the application. | |
-widgetcount |
At program end, shows the number of widgets left undestroyed and maximum number of widget reached. |
The interaction of Dolphin’s KDE-based styling with Gnome’s way of styling windows is mysterious. I think nobody has a perfect understanding of how the various theming engines interact, and the best approach is to make experiments. The deepest analysis I know of, by the blog “Homo Ludditus”, is subtitled “the horror”. I recommend a reading, at the very least to know what you are going into if you really want to control how Dolphin is rendered outside KDE.
As shown in the previous gallery, an effective way to partly customize Dolphin’s appearance is to choose a theme and add a stylesheet. The utility qt5ct
can help to set the defaults without using command line parameters every time. However, the final result of the theme is partly a surprise, and the stylesheet also arcane: there is no documentation about the classes that Dolphin uses.
One of my biggest curiosities about Dolphin was the color of the lines in the detail view. After many experiments, my conclusion is that the odd-numbered lines can only be set by the theme, while the even-numbered can be themed using two approaches: the kdeglobals
file or a custom spreadsheet.
One can edit ~/.config/kdeglobals
and add a section like this:
[Colors:View]
BackgroundNormal=255,255,0
In my experiments, only BackgroundNormal
had an effect. Other options like BackgroundAlternate
were ignored. The worst, however, is that the color was only applied to the tabs opened at the start of Dolphin. New tabs created in the application were left unstyles, and the only way to apply the new line color was to close and restart the file manager.
BackgroundNormal=255,255,0
As with kdeglobals
, even using a stylesheet results the tabs already open at program start are styled differently than those opened afterwards.
A stylesheet is however more flexible. We can apply a background image, for example:
DolphinViewContainer > DolphinView > QAbstractScrollArea {
border-image: url('/home/me/Pictures/my-background.jpg') 0 0 0 0 stretch stretch;
}
Alternatively, we can set a color:
DolphinViewContainer > DolphinView > QAbstractScrollArea {
background-color: #FF3388;
color: #3377ff; /* this will be ignored, it's just here for demonstration */
}