QComboBox: change one option of stylesheet - qt

I have some particular QComboBox like this (osx style):
that I want to highlight programmatically. I used
combo->setStyleSheet("background-color: yellow");
and the background get changed, but then the whole style of my widget becomes ugly like this:
as you can see, the background is ok, but dropdown button got changed with '90 motif style (old good days...)
Is it possible to just change the background?

Some of the stylesheet rules will trigger a fallback to the Windows style, see my answer here.
One option to style the background is by using QProxyStyle.
Changing the palette might also work.

Related

Are there different here maps style css files?

Right now I am using the default maps ui: http://js.api.here.com/v3/3.0/mapsjs-ui.css.
But I am not completely happy with the black controle buttons (mapsetting, zoom).
On js api start page here maps is using white buttons without round corners, exactly what I want.
Is there a secound css file I did not found or will it be replace current black style in near future?
It is not the problem to change style by my own, but I would prefer a other way.
There is only one CSS file with the black color scheme. My guess is, the developer.here.com color scheme is a custom override of the styles. But then again, the mapsjs-ui.css file uncompressed making your own color overrides relatively simple.
I agree that if they change CSS rules it's your issue. However, that doesn't seem to have happened, like... ever until now.

How do I set or change specific style sheet properties in Qt for a QWidget, without resetting the whole style sheet?

I've been searching for a while for an answer to this problem and I'm rather surprised that I have not found a solution. I'm working with Qt on Mac and would like to customize QPushbuttons and other QWidgets, but I want to maintain the native look somewhat as well. For example, if I want to remove the margins of a QButton using style sheets, I do:
QPushButton btn(this);
...
btn.setStyleSheet("margin:0;");
This indeed removes the margins, but it also removes the native style already set for default buttons. Of course, I just want to modify margins using style sheets, how do I do this?
Also, I would expect that btn.styleSheet() would return the native style sheet, but it is blank by default. Only when I set my own style sheet, does it return a valid value, but only for the property I set. I get that setStyleSheet would reset the style sheet, but how do I modify certain properties and leave everything else as is?
TL;DR: It can't be done that way.
The native style cannot be generally expressed as a CSS style sheet, thus styleSheet() is empty by default on all styles. Thus, unfortunately, it's not possible to change native style elements one-by-one, since typically they are drawn by the platform APIs that allow little if any customization.
For examples, a QPushButton is drawn by the native calls on both OS X and Windows.
In the specific case of the margin, though, you can easily work around by creating a proxy style that returns smaller control rectangle and crops and transforms the painter before passing it to the base style. This also works for colorization/color substitution etc. You basically have to accept that the base style has to do the drawing, and then it's up to you to tweak it.

How to set QPalette ColorRole properties with stylesheets

I am using a pretty lightweight custom palette that just defines a few colors and properties. I am attempting to transform it into a stylesheet but I am running into problems. For example, what is the QPalette::Base equivalent in stylesheets? Do I have to change the background color for every widget individually?
I tried setting a few stylesheet properties for the QWidget but then I got undesired results for widgets with borders. Layouts were showing borders when I didn't want them to, so I found myself writing a lot of stylesheet definitions to add/remove borders.
The gist of the question is, is there a good way to convert a palette to a stylesheet?

CSS: Get "disabled" input background color?

Is there a special CSS system color equivalent to the system's disabled text input background color? I know there's one for the disabled text color (GrayText), but I can't find one for the background color.
To make it more clear, I'm looking for the background color that gets set when you do something like:
<input type="text" disabled />
I don't want to restyle disabled inputs; I want to use the existing system style elsewhere.
Edit:
To be even more clear, I'm looking for the system color keyword, not the actual color. For example, to use the system's defined disabled text color, you would do this:
<span style="color: GrayText;">This text looks like disabled text in your operating system</span>
I just can't find the one for the background color.
I encountered this issue while trying to style a javascript replacement for a select. While there has been no progress in the CSS spec, there is a jQuery alternative.
$("input:disabled").css("background-color")
This returns a RGB color from an already disabled input, so unfortunately it's not as flexible as a CSS color, but it will work across browsers and reacts to custom colors applied to disabled elements through CSS.
This isn't the purpose of the keyword - the use of colour [I believe] is technically up to the browser vendor - if they observe the OS preferences then thats up to them.
There are a small number of color names originally in the W3C spec. However these were extended to include the list of X11 color names that were supported by most browser vendors.
Together those lists are all the valid names acceptable in a browser.
According to the latest CSS spec, there is no system color keyword for "disabled" background color.

Remove highlight on a selected button from a ToggleButtonBar

Well, title explains all. I'm trying to get rid of the highlight that comes around of the selected button in a ToggleButtonBar
To get the exact look you want your best bet is to jump in Flash, Fireworks, Photoshop, etc and tweak a button skin to your liking. The border is part of the skin. You can create a programmatic skin as well.
A quick fix is to set the highlight the same color as the button.
ToggleButtonBar{
button-style-name: "myButton";
}
Button.myButton{
theme-color: #999999;
}
Mind you...it is purely a quick fix and will tweak your button hover color as well so only use it as a small win.
I eventually find how to resolve it, quiet simple actually! (Thanks to the KapInspect tool)
I just had to create a custom skin for the selectedDownSkin style

Resources