Edit Qt Qapp style setting to create dark mode - c++

Just found some awesome free (speech) software to speak to some lab equipment. The background is very white though and I would like to put it in to dark mode. I know nothing about C++. In main.ccp I found this qApp->setStyle(QStyleFactory::create("Fusion")); couldn't see any hex or rgb values that weren't tied to buttons, so i'm wondering if "Fusion" describes the background colour, and if so is there something I can replace it with to create a dark version of this software?

Related

Change the background color in WebStorm

I have a theme installed. I just want to make the background darker than what it is, it really helps especially because I have vision problems. I guess I need to use the "Color scheme" from options, but I really couldn't find anything to change the background.
To change the background color of the Editor tab, do the following:
File | Settings (WebStorm | Preferences on macOS)
Editor | Color Scheme | General
Make a copy of the Color Scheme (if it's a bundled one or provided by a plugin) so that you can customize it (although the IDE should do that for you automatically)
Locate Text | Default text entry and change the background color there.
An example: modified Dacrula theme with bright yellow background (yeah, looks completely unusable, but good for illustration purposes):
Please note: some languages can provide own background colors. E.g. PHP -- a typical PHP-code only file will have all code inside a single <?php tag so you may see a different background color for PHP code compared to other languages. Test and adjust it as needed.
Note #2: GUI Theme (which is about styling the rest of the IDE GUI): it always linked to some Color Scheme (so the GUI and Editor area have similar colors). When you will be switching between GUI Themes make sure to double check the applied Color Scheme as well (if you need to use your custom one).
Useful shortcut: View | Quick Switch Scheme -- it will bring a popup menu that allows quickly switching different themes and schemes.

How to recognize that an application is running in dark theme on Linux?

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.
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

Qt KDE theme stylesheet

I am using KDE theme Breeze Dark. Since all my Qt applications have changed its colors. Earlier my applications wasn't altered by KDE themes but now I am receiving message: "kf5.kiconthemes: "Theme tree: (Breeze)". I was changing background colors in my apps using stylesheets. Now due to changed fonts colors it is impossible to read (white text on very bright background). What is more I am not able to get default background color.
qDebug() << qApp->styleSheet(); gives me empty string.
How to get background color? I would like to use it setting my own backgrounds (showing priority of a task, little more reddish background and so on).
You can access to default theme colors via QPalette.
If you want just to change colors of your widgets - QSS is overkill. QPalette is more than enough.

vs2010: Gradient background in a windows application

I am working on visual studios 2010 and c++. I am trying to change the background color of my basic windows app i want to put gradient colors to it like how skype and other programs do is it possible? As far as my guess is that i have to add gradient brush on the WNDCLASSEX.hbrBackground so far i could only find this
http://msdn.microsoft.com/en-us/library/windows/desktop/dd371488%28v=vs.85%29.aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/dd799414%28v=vs.85%29.aspx
But i could not make it work as a whole background, i am just making guesses as i am completely lost and an example code or description on how to achieve this will be really helpful.
If you want to support versions prior to Vista, you needed to handle WM_ERASEBKGND message in your window proc and do the whole painting of the background yourself. Read about GDI or GDI+ at msdn on how to do it.

How to change button color?

I am developing a GUI application using Embarcadero VCL c++ IDE for windows OS. As part of this project, I have to change color of button with respect to an external state.
I understood that windows32 API will not allow to change the color of button.
Could you please suggest me, how to change button color?
Do you wish to change the background-colour of the button, or the text-colour of it?
Since windows has used visual themes for some time now, if you have commctrl loaded and include a manifest file, the button will be drawn using the default (current) theme.
Options I can see include (a) custom-drawing the background (b) changing the text-colour in the normal draw process (c) drawing the button without a theme (i.e drawing a 'flat' button).
You could simply draw a bitmap-button, changing the bitmap depending on the state of the button. You could also use a single bitmap, tinting it using the HSL or HSV colour-space, depending on the state.
As for the flat type of button, I think you can probably change it's background-colour in much the same way as you can change the colour of the text - by intervening during the standard draw process and changing the colour from 3D_FACE (or whatever it is, I forget) to whatever you'd like.
If you look at the calculator included with windows XP, you can see an example of changing the text colour.
CodeProject.com likely has a stack of articles that would help in this endeavour. :)