Disabled QGroupBox title shadow (aka etching) - qt

Look thoroughly at the disabled QGroupBox title (see attached image).
You'll notice a tiny white 1-pixel shadow under the title's letters.
It's barely noticeable on default style sheet, but it can be much more annoying if you set dark background and text color.
What can I do to disable this shadow, or at least change its color?

What style are you using? It looks like the 'basic' Windows style. If you want to get rid of the text shadow, you can implement your own style and change the way the text is drawn for disabled group boxes. Read more about about QStyle and how to create a custom style here. The link is for Qt 5.1, but the principle is the same for Qt 4 as well.
An easier way would be to simply change the palette for the QGroupBox object. Change the color identified by color group QPalette::Disabled and color role QPalette::Light to any color with the alpha channel set to 0, e.g. QColor(0, 0, 0, 0). This will effectively disable the text shadow. However, it will also disable the shadow of the lines so it might not be what you want.

I've found a solution:
Unfortunately, you can't remove disabled text shadow (aka etching), but you can change its color using dirty workaround:
It looks like shadow effect always takes its color from the ColorGroup "Disabled" and the ColorRole "Light" of the current palette. So, you just set this color to the background color of your widget:
QPalette p = myWidget->palette();
p.setColor(QPalette::Disabled, QPalette::Light, QColor(0,0,0)); <- place your widget bg color here
myWidget->setPalette(p);
I've found this solution here

Related

Resetting an attribute to a default style value in XAML Xamarin.Forms

I have a label which looks like this:
<Label Style="{StaticResource myStyle}" x:Name="TestLabel">
The bound style sets the background color of the label to red color.
Then later on in the code, I do this:
TestLabel.SetValue(Label.BackgroundColorProperty, Color.Green);
This sets the background color of the label to green.
But then, I need to clear the green color which I set manually, and I need to reset it to the default value, dictated by the bound style (in this case red).
So I do this:
TestLabel.ClearValue(Label.BackgroundColorProperty);
But instead reverting back to red, the background color gets removed completely and becomes transparent (which is the default setting for a label, without any styles attached to it).
(One solution that offers itself would be TestLabel.SetValue(Label.BackgroundColorProperty, Color.Red);, but I cannot do this, since I need the color to revert back to whatever the style attached to it says it is, since different labels have different styles attached)
The best way to set or reset attribute use trigger instead of manual set.
https://developer.xamarin.com/guides/xamarin-forms/application-fundamentals/triggers/

Modify default widget text color with applied stylesheet of QTreeWidget items

I have a QTreeWidget (however this question relates to any kind of widget) in which I have items which, under certain circumstances change their foreground color to red using item.setForeground(0,QBrush(QColor("red"))).
Later they can change their foreground color back to black. But the problem is that if the widget has been set some stylesheet which has changed the foreground color to other than black, I am in trouble. My question is how to revert the color of an item to the default color used by the widget for text color given the applied stylesheets?
For example if I apply a dark stylesheet which makes widget background dark and default text color white, first I can see white items, then they change to red and then they become black. But I want them white again. But I do not know how to find that it is white (and not black) color they should change to.
I tried this:
1) if I use item.setForeground(QtGui.QBrush()) which I hoped would use empty and therefore default brush, I always get black text
2) if I query the text color treeWidget.palette().text().color() I always get the same color regardless of the stylesheet
This question doesn't really apply to "any kind of widget", because there is no guarantee that setting the foreground colour will always work. To quote from the docs for QPalette:
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 XP, Windows Vista, and the Mac OS X styles.
However, if the question is restricted to model items (such as QTreeWidgetItem), you can clear the current settings like this:
item.setData(column, QtCore.Qt.ForegroundRole, None)
On platforms that do allow changes via the palette, you could get the default palette like this:
palette = QtGui.qApp.style().standardPalette()
which should then allow you to restore the original values.

How to modify c3.js legend's text color

I am trying in vain to change the font color of a c3.js graph's legend.
With chrome's style inspector, i could change for example the font-size of the text but not the color.
Attaching a screenshot with the above mentioned properties (font-size and color).
Any hints please?
It is not color that you should change, instead change strokeor fill. See this tutorial for an explanation and difference between stroke and fill.
Add CSS styling for the legend item in your css file. Use fill instead of color because css property color is not valid here
.c3-legend-item {
fill: #9fabb1;
}

Shading of icons in a Qt combobox possible?

How can I set a "shading" for QCombobox icons?
I have a QComboxBox with text and icon entries. The icons are nation flags here. The combobox background color is white by default (on Windows). The problem is with the Japan flag, because just a red filled circle is displayed. In other words, I cannot distinguish the white flag color from the combobox background. My workaround is to overrule the combobox base color and set the RGB value to 3*250. Furthermore I don't think it's a good idea to draw a dark border in the original PNG image of the flag.
P.S.: What do you use as workaround for white on white? (I want to know if my workaround is the best solution...)

Changing the Shadow Color of a Disabled QComboBox also changes the color of Active Text

I'm currently trying to change the style of of disabled QComboBox, including the shadow drawn behind the text. Annoyingly enough, it seems the text shadow cannot be styled in the style sheet, which would be my preferred solution, but that's not the issue at hand.
I've have managed to change the shadow color in my code using setColor( QPalette::Disabled, QPalette::Light, QColor( #, #, # ) on the QComboBox's palette. While this "works". I come into the issue that the text color for the active state (but not the list view) also takes on that color, completely overriding changes made by the style sheet. I was under the impression that style sheet was meant to trump the palette.
Ideally, the fix for this would be a 100% style sheet solution, but google searches for me have had no positive results as far as setting the shadow color in the style sheet. I did find something about an etch-disable-text property, but that seems to only be psuedo science.
Calling setColor( QPalette::Active, QPalette::ButtonText, QColor( #, #, # ) ) on my palette before assigning it to by QComboBox resolves the issue, but I'm still looking for a style sheet solution.

Resources