PDA

View Full Version : textEdit background color



briang
23rd October 2009, 06:24
G'day all

How can i set the background color in lineEdit, textEdit, ect to
red. then how to make it a flashing red...

thanks in anticipation
briang

schnitzel
23rd October 2009, 06:46
I use stylesheet property in QtCreator. The flash effect you could probably do with a timer.

ps: googling 'set background QLineEdit' resulted in some decent examples ;)

Erik_Klein
5th November 2009, 18:12
hey brian, there are couple of ways to do, it all depends on what exactly you need to style.

My experience is using Qt Designer, so if you are familiar with it thats' great - if you aren't, then its a great opportunity for you to have a look at it.



If its for instance to style all QLineEdits and and QTextEdit, open designer...

1. create the UI as needed
2. Right-Click on the top-level object
3. Once you right click, a "set stylehsheet" option should appear
4. just write
".QLineEdit, .QTextEdit
{
background-color: red;
}"
5. and thats it!(images attached for further guidance)

Note: adding the "." before the object name as i did, will make the style to be applied universally to every QLineEdit(or whatever object you choose) in the UI .


thanks,

smacchia
5th November 2009, 18:24
If you're not using the gui builder, you can do the following:

QLineEdit *edit = new QLineEdit;
QPalette p = edit.palette();
p.setColor(QPalette::Base, Qt::red);
edit->setPalette(p);

Look at the documentation for QPalette too.