AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Qt creator dark mode5/1/2023 ![]() ![]() Also, there is no Qt API to find out whether the system is running with a dark or light color scheme. And if darkmode=2 is specified, then a dark palette is used even if the style cannot possible work with a dark color scheme. The problem is still that the dark palette is not read from the system and needs to be hand-crafted, unless darkmode=2 is specified. ![]() int main(int argc, char **argv)Īpp.setStyle("fusion") // looks good with dark color scheme > lor(QPalette::Window).lightness() Īpplications can then use a style that looks good with a dark palette, set a dark palette, and automatically get a dark window title and frame. Return lor(QPalette::WindowText).lightness() To determine whether the palette is dark or light, we compare the window color with the text color: static bool shouldApplyDarkFrame() In Qt 6.4 we changed the default behavior depending on the application default palette: if the application palette is dark, then windows automatically use the dark window decoration. The default up to Qt 6.4 was to support neither. The value '2' will in addition make Qt read and use the dark system palette. The darkmode value of '1' enables window decoration theming, allowing applications that implement a custom palette and corresponding style to have a consistent window frame and title bar. Or through an environment variable (preferably set in the main function via qsetenv("QT_QPA_PLATFORM", "windows:darkmode=")). > gallery.exe -platform windows:darkmode=2 That opt-in is a parameter to the QPA platform, and could be set through a command line option when starting the application: > gallery.exe -platform windows:darkmode=1 Since version 5.15, Qt has provided an opt-in way to use the dark system palette, or to respect the dark system theme at least for the window decoration. Applications and system dialogs not written with the relatively new WinUI library don't look "fluent", often don't support the dark color scheme, and some control panels deeper down in the tree still look like they used to with Windows 2000. ![]() However, that system is not available through UxTheme, and so it is perhaps not a surprise that on a Windows 11 system, even the operating system UI comes in a mix of styles. ![]() In recent years, Microsoft has moved towards the Fluent design system, which the Windows 11 system UI is based on. So while Qt can read a dark palette from the system, we can't really use it when the UxTheme based Vista style is used - we'd get dark theme colors for some UI elements, but light UI control assets from the system, leaving the user with an unusable user interface. And in that design system, there is no "dark mode", and there is no documented way to get the dark control assets through that API. However, the control assets we get are still based on the Aero design system of Windows Vista. The UxTheme API is still present on Windows 11, and Qt still uses it to render the elements of user interface controls in the native Windows Vista style. That did not really happen, and while buttons are nowadays just a flat frame with rounded corners, they - fortunately, I suppose - still have no holes. The expectation was perhaps that a community of creators would build lots of custom UI themes for the UxTheme library, similar to the many cursor and icon libraries. And the QStyle API is still largely the same in Qt 6's QtWidgets. The implementation of the Windows XP style later became the basis for the Windows Vista style, and for Qt 6, we use that implementation in the native Windows desktop style for Qt Quick Controls.īut fashion changes, and not all technologies evolve as originally intended. We had already been working on Qt's Windows XP style implementation based on the Windows XP preview builds, and used the new native APIs to draw the various elements of user interface controls. That work influenced a lot of the QStyle API design, just in time for the then-upcoming Qt 3 release. I remember talks about round UI elements, buttons with holes, gradients, semi-transparency, even animations! The possibilities seemed both endless and scary for people in the audience that had developed custom controls with MFC or Win32 APIs. Proper UI theming was introduced with Windows XP through the Win32 APIs from the UxTheme system library. I went to the Microsoft's TechEd conference in Barcelona in 2001 to learn what we can expect from that framework over time. Windows 3.1 already had custom mouse cursor and icon packages, and I filled several floppies and later DVDs with background images and sound effects inspired by the latest movies. On Windows, theming and personalisation have a long history. Qt has supported the dark appearance setting on macOS for many years, and with Qt 6.5 we are bringing better support for dark themes to Windows as well. With recent Windows 10 builds, and with Windows 11 even more so, dark color schemes have at last landed as a mainstream personalisation option on the Windows desktop. ![]()
0 Comments
Read More
Leave a Reply. |