I've developed an application which uses qscintilla as a text editor. I also implemented custom lexer to highlight language specific keywords. So far styles for highlighted keywords are hardcoded in mine application and it looks quite ok in the default theme on Windows/Linux(Ubuntu)/Mac.
The problems appears when user chooses a dark theme (on Linux). Depending on QScintilla version some parts of editor do reflect current theme colors while other don't. Moreover mine custom styles render dark blue letters on dark grey background.
I'm looking for some Qt class, which will allow me access of the current system theme. I do not want to define styles for mine application widgets. I want to know what is system default non-proportional font, what is it's size, color, ... If I knew that dark scheme is used I would choose complementary colors for keyword highlighting.
I checked docs for QStyle, QPlatformTheme and other qt classes and it seems to me that these serve more for defining of new styles, then for describing the current style.
Enable dark mode in Ubuntu 20.04Press the super key (Windows key) and start typing settings to search for the Settings application. In the Settings application, go to Appearance section and you should see three variants of the theme: Light, Standard and Dark.
Use the system setting (Settings -> Display -> Theme) to enable Dark theme. Use the Quick Settings tile to switch themes from the notification tray (once enabled). On Pixel devices, selecting the Battery Saver mode enables Dark theme at the same time.
To enable Global Dark Theme, go to Appearance tab and change Applications in the Themes section to Adwaita-dark.
For GTK+-3 applications, you can enforce the dark theme variant using GtkSettings' settings.ini: For non-GTK+ applications like vnc, you can still enforce dark window decorations by setting the _GTK_THEME_VARIANT X property of type UTF8_STRING to dark.
No, but you may use my fairly comprehensive stylesheets that should look excellent on most platforms (it's inspired by KDE's Breeze Theme, which is a dark theme that is quite elegant).
With gtk+ ≥ 3.12 you can load a specific theme and its variant (dark, light) on a per-application 1 basis via the environment variable GTK_THEME=theme:variant. As per the gtk+ reference manual: GTK_THEME.
QT Creator provides Dark theme. To Enable it In Qt Creator Application Goto Tools -> Options -> TextEditor -> select theme as Dark
For the system colours, you can use the group/role of the QPalette
class.
For the system fonts, you can create a QFont
using e.g. "Serif", "Sans Serif", "Monospace", etc with an appropriate style hint to discover the defaults.
NB:
From the Qt Docs:
Warning: Some styles do not use the palette for all drawing, for instance, if they make use of native theme engines. This is the case for both the Windows Vista and the macOS styles.
Here is some python code using QPalette that works for me on Linux:
label = QLabel("am I in the dark?")
text_hsv_value = label.palette().color(QPalette.WindowText).value()
bg_hsv_value = label.palette().color(QPalette.Background).value()
dark_theme_found = text_hsv_value > bg_hsv_value
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With