Anyone know how to change the background color of a text field that is disabled?
When I set the Enable property to FALSE on a text field object - the background color changes to WHITE. I am unable to change it to another color. I have tried using the CSS stylesheet to do so but it has no effect on the color
I have tried different variations
QLineEdit[type = "CueDisplay"]:!isEnabled {
background: rgb(0,0,0);
}
QLineEdit[type = "CueDisplay"]:read-only {
background: rgb(0,0,0);
}
QLineEdit[type = "CueDisplay"] {
background: rgb(0,0,0);
}
None of the above work. They seem to be correct syntax wise as they do not cause any faults when the style sheet is loaded.
Text Field Background Color when disabled
- mkoller
- Posts:741
- Joined: Fri Sep 17, 2010 9:03 am
Re: Text Field Background Color when disabled
When creating a TextField, the default color for the background is _Window - this is important when wanting to apply a stylesheet.
Keep this background color.
When you now want to have the TextField always with black background color, also when disabled, use a stylesheet with
Keep this background color.
When you now want to have the TextField always with black background color, also when disabled, use a stylesheet with
Code: Select all
QLineEdit { background: black }
- Gertjan van Schijndel
- Posts:634
- Joined: Mon Aug 02, 2010 10:37 am
Re: Text Field Background Color when disabled
Lori Kefalos wrote:
I have never seen the pseudo-state 'isEnabled' before. In the Qt Style Sheets Reference I only see the 'disabled' and 'enabled' pseudo-states.QLineEdit[type = "CueDisplay"]:!isEnabled
- lakefalos
- Posts:27
- Joined: Thu Feb 01, 2018 3:13 pm
Re: Text Field Background Color when disabled
Hi. Thanks so much for your quick replay and it worked! I had already had the default colors set as you stated. I had seen that recommendation in the previous post.The format QLineEdit { background: black } seemed to be the key. Thanks again!
- lakefalos
- Posts:27
- Joined: Thu Feb 01, 2018 3:13 pm
Re: Text Field Background Color when disabled
I saw that parameter on their website and tried it along with a couple others. It didn't cause a syntax error but it didn't fix my issue. It turns out I did not have to differentiate between enabled and disabled. It worked with this format QLineEdit { background: black }