QML label in any color except white? - qt

I am using pyQt with QML for creating GUI.
I have one qml file (main.qml) that contains ApplicationWindow.
Inside, I have a label that I want to color white:
Label{
id:lbl_absPos
/*
some anchors and stuff
*/
font.pixelSize: _display_font
color: "black"
width: _display_width
height: _display_height
text: "Simple Text"
background: Rectangle{
anchors.fill: parent
color: "white"
border.width: 2
border.color: "black"
}
I know this code works, because any other color works, e.g.:
background: Rectangle{
anchors.fill: parent
color: "steelblue"
creates a steelblue background color of the label. But when I put "white", i get gray color of the window behind, like it is transparent... how is that possible? Is that a bug or I am doing something wrong?

I found out the problem. By default, the background of the ApplicationWindow seems to be white but I somehow thought it should be lightgrey.

Related

Changing style of mui stepper icon

I would like to change the color of the icon from
to this :
I know that it's not .Mui-active nor .Mui-completed , I tested .Mui-disabled but it doesn't work
here is the link to the sandbox :
https://codesandbox.io/s/horizontalnonlinearstepper-demo-material-ui-forked-u2yt0e?fontsize=14&hidenavigation=1&theme=dark
Any help ?
This one was a bit tricky, I had to add quite a few styles to achieve that.
First I've given every icon a round and visible border. The second style object ensures that the icon color is white and it excludes checked icons since we want them to look like usual.
".MuiSvgIcon-root": {
borderRadius: "50%",
border: "1px solid #1976d2"
},
".MuiSvgIcon-root:not(.Mui-completed)": {
color: "white"
}
Next the text is being filled with the same color as the border and I made it more bold to be more readable.
".MuiStepIcon-text": {
fill: "#1976d2",
fontWeight: 500
}
Last but not least the active icon should still remain the same so I've reduced the margin from -4px to -3px since the border adds 1px in every direction. The check icon should remain white so thats styled with fill: "white".
".MuiSvgIcon-root.Mui-active": {
color: "#1976d2",
padding: "3px",
borderRadius: "50%",
border: "1px solid #1976d2",
marginY: "-3px"
},
".Mui-active .MuiStepIcon-text": {
fill: "white"
}
And this is the result:
Live Demo

How to change the text color in dependency to the background

I'm creating an application for a paint shop. They have a lot of colors (> 4000)
To show the color, I create a badge with the color as background color.
.custom_badge {
background-color: var(--bg);
border-radius: 10px;
height: 25px;
padding: 0px 10px;
color: white;
font-weight: 500;
}
If the background color is as example yellow, I like to show the text in black. If the background color is dark, i like to show the text color white.
I searched for inherit.
Is there a way with inherit?
Or is there an onther solution?
I don't think there is a way in CSS to do this, but it can be done with Javascript :
let RGB = window.getComputedStyle( document.body ,null).getPropertyValue('background-color');
RGB = RGB.replace(/[rgb \(\)]/gim, '');
RGB = RGB.split(',');
let textColor = (RGB[0]+RGB[1]+RGB[2]<300) ? '#fff' : '#000';
console.log(textColor);

Is there any way to change combo box arrow button color in javafx?

I want to be able to change the combo box arrow button color not background color but the color of the button only to the color of the border and text fill both of which are set to #f0f0f0.
Is It possible, if so then how?
Using css selectors you can change the arrow, and arrow button color however you want
.combo-box .arrow {
-fx-background-color: black;
}
.combo-box .arrow-button {
-fx-background-color: white;
-fx-size: 5;
}
to do this in code without editing the .css file, assuming your ComboBox is named comboBox
comboBox.lookup(".arrow").setStyle("-fx-background-color: black;");
comboBox.lookup(".arrow-button").setStyle("-fx-background-color: white;");

Overriding css of a TextField component in Native Script

I am trying to change the styles of a TextField element in Native Script for Android. At the moment I have got the text field displayed in black. I want to turn it white. Since the background is dark.
<TextField cssClass="tf_password" hint="Password" id="password" text="{{ user.password }}" secure="true"/>
Any help is appreciated.
If you want the text white and the background black you can set this in your CSS file:
#password {
background-color: black !important;
color: white !important;
}
Your problem is not how to change the text color of a TextField but the placeholder color:
#password {
background-color: #000;
color: #fff;
placeholder-color: #fff; /* ideally different color than normal color */
}
You can see a working example in NativeScript Playground
If you want to change the color of TextField, it that case you can simply give color property to TextField. If you are looking to change hint color than you can use the placeholder-color property:
<TextField hint="Password" id="password" text="{{ user.password }}">
</TextField>
The CSS would be
TextField {
color: #ffffff; // used to define color of input field
placeholder-color: #000000; // used to define color of hint
}

JavaFX: Change text color of textarea

Alright so I can't get this to work at all. I've checked the CSS analyzer in the scene builder and I came to the conclusion that the way to change the text color in a textarea is something similar to this:`
.text-area .text {
-fx-fill: #1e88e5;
-fx-font-size: 32px;
}`
Problem is that the color doesn't change nor does the font size. Where am I going wrong here?
How about this:
.text-area {
-fx-text-fill: #1e88e5;
-fx-font-size: 32px;
}
Update: the Style class text-area doesn't have a descendant named text. it has an immediate child named scroll-pane and a decendant named content .for more information see: this link

Resources