daplis_rtp.gui.title_bar module
A dark title bar on every window, whatever the theme.
The title bar, the frame and the three buttons in its corner are drawn by Windows, not by Qt, so the stylesheet that themes everything inside the window never reaches them: left alone, the bar stays the light system default over a dark application. Windows 10 (20H1 and later) and Windows 11 let a program ask for the dark version of the bar, one window at a time, through the desktop window manager.
The bar is dark on every theme, light ones included. It is part of the window rather than of the content, and one bar that never changes is calmer than one that flips with the colours below it.
Every top-level window is caught as it is shown, through one event filter on the application: the main window, Preferences, the user guide, the pixel mask, and the message boxes Qt builds on the fly. A window added later needs nothing doing. The show event arrives before Windows first draws the frame, so the bar never flashes light.
The native file dialogs (“Browse”) are drawn by Windows itself and follow the system setting instead. Elsewhere than Windows this does nothing, and the desktop decides.
- daplis_rtp.gui.title_bar.dark_title_bar(window)[source]
Ask Windows for a dark title bar on one top-level window.
Returns True when Windows accepted it, and False when it did not or could not be asked: another platform, a Windows too old to know the attribute, or a window without a real native handle (Qt’s offscreen platform, in the tests).