Is it possible to make existing icon lighter on hover - qt

For example I've QToolButton with custom icon
Can I make this icon lighter on hover using QToolButton:hover qss?

Could you please try below options:
option 1:
Try PaletteRole property type
http://doc.qt.io/qt-5/stylesheet-reference.html#paletterole
As you require for hovering,
QToolButton:hover { color: palette(light); }
option 2:
Create a different image with lighter view Icon.
And set the background when you hover on it.
QToolButton:hover { background: url("LighterView.png") ; }

Related

Codename One CSS Material Icon color not changing

I have created an application to test the new CN1 CSS support.
The plugin is great and everything works fine and out-of-the-box, except that the material icon on a button does not change its color with the button's text color. It just stays always the same (black) color.
Before using the CSS support, I changed the theme editor's default foreground color setting to reach the material icon, but now the theme editor seems to be dis-attached from the styling and it does not have any effect anymore.
Is there a UIID for the icon or any other way to change the color of the material icon?
Here is my code:
FontImage icon = FontImage.createMaterial(FontImage.MATERIAL_CHECK, "TitleCommand", 3);
Button buttonTest = new Button("Test css");
buttonTest.setUIID("ButtonTest");
buttonTest.setIcon(icon);
And the CSS:
ButtonTest {
color: red;
}
try it
FontImage img = FontImage.createMaterial(FontImage.MATERIAL_THUMB_UP, style);
Just to post a complete answer that might be able to guide someone:
Style style = new Style();
style.setBgColor(ColorUtil.GREEN);
style.setFgColor(ColorUtil.WHITE);
style.setBgTransparency(255);
FontImage imageBack = FontImage.createMaterial(FontImage.MATERIAL_NEXT_WEEK, style);

Keeping the same selection color in a TableView whether it's active or not

I'm using QTableView class in my GUI and I would like the selected row to have the same color whether the TableView is active or inactive.
I tried to set this CSS stylesheet to achieve this:
QTableView:!active {
selection-background-color: palette(Highlight);
selection-color: palette(HighlightedText)
}
On Linux, it works just fine, but on Windows 7, when the TableView loses its focus, the text turns black instead of staying white (the background stays blue, so that part is OK). Am I missing something here ?
You also have to style text color, for example just add:
QTableView:!active {
...
selection-color: white;
}
This works well in python
pal = tbl_list.palette()
pal.setColor(QPalette.Inactive, QPalette.Highlight, pal.color(QPalette.Active, QPalette.Highlight))
tbl_list.setPalette(pal)

Getting rid of pressed effect in JavaFx toggle Button

How can I get rid of the pressed effect of javafx toggle button? Essentially, I want the look and feel of the button to be the same except the background image.
In your CSS file, you can do
.toggle-button:armed {
-fx-color: -fx-base ;
}
You might also want to remove the hover effect:
.toggle-button:armed, .toggle-button:hover {
-fx-color: -fx-base ;
}

Is it possible to change the ToggleSwitch colour in ControlsFX

I'm using ToggleSwitch in controlsFX which is wonderful. I'd like to change the colour from the default sky blue to another colour. I've used css styling but it changes the background behind the ToggleSwitch. Is there a way to customise the actual switch?
Here is my ToggleSwitch:
<ToggleSwitch styleClass="purple" text="No"/>
Here is my styling:
.purple{
-fx-background-color: #57379b
}
Style the background of the thumb area of a selected ToggleSwitch:
.purple:selected .thumb-area {
-fx-background-color: #57379b;
}

Changing the default color on flex validation errors

The examples I've seen seem to show how to change the color that shows when the user actually hovers over the textinput field.
However when the validation fails, a generic textInput border qill have a red line over it. My CSS file uses a border skin for the textInput, so I can't see this line.
I was hoping there was a way to highlight the text box when it failed validation, or re-enable the red line feature. I don't want to get rid of my CSS cos it'll totally blow my color-scheme, but any tweak allowing the error line to show would be much appreciated.
This is the CSS:
TextInput, TextArea
{
border-skin: Embed(source='/../assets/images/input_bg.png', scaleGridLeft=8, scaleGridRight=20, scaleGridTop=8,scaleGridBottom=9);
padding-top:2;
padding-left:2;
font-size:11;
}
anything that extends UIComponent (both TextInput and TextArea do) has a style called errorColor. It defaults to red. You can change this to whatever you want.
Additionally, if you've got an image that you are using as a border, you should probably remove the pixels from the middle so that it is an actual border instead of an overlay.
The only way I've managed to find, is that Validator will change the component's borderColor style. I don't think it can be achieved using an image- you'll have to embed the image in a basic GraphicRectangularBorder subclass or similar. You can then add this to your skin class:
override public function styleChanged(styleProp:String):void
{
super.styleChanged(styleProp);
if (styleProp == "borderColor")
{
if (getStyle("borderColor") == getStyle("errorColor"))
{
// show error outline
}
else
{
// hide error outline
}
}
}

Resources