View Full Version : Qt4 - QTextEdit - background color
impeteperry
12th May 2006, 02:25
Hi, I have several QTextEdit widgets. I have no Idea on how to set the background colors. In Qt3 I used
teErrorMessages->setPaletteBackgroundColor( QColor( 240, 240, 255 ) ); I have looked at designer, Qt3 to Qt4 docs. the Qt4 demos, and am still at a loss.
Any help would be most appreciated.
munna
12th May 2006, 05:04
setBackgroundRole(QPalette::ColorRole role) in QWidget
Text entry widgets usually use QPalette::Base as the background color.
QPalette p = textEdit->palette();
p.setColor(QPalette::Base, QColor(240, 240, 255));
textEdit->setPalette(p);
impeteperry
12th May 2006, 13:27
Thanks for the prompt reply, but still have a problem.
I am using designer.so entered
QPalette p = ui.helpBox->palette();
p.setColor(QPalette::Base, QColor(240, 240, 255));
ui.helpBox->setPalette(p);.when I compiled I got
edpform.cpp:167: error: expected primary-expression before ‘.’ token
Line 167 is the ui.helpBox->setPalette(p);
so I went back in designer and opened the "palette" in the Property Editor for the helpBox ( QTextEdit Widget ). I was able to change the color there, but I want to change the background color from within the program.
thanks
jacek
12th May 2006, 13:36
ui.helpBox->setPalette(p);.
There's a dot after semicolon --- remove it.
impeteperry
12th May 2006, 15:05
boy you have better eyes then I do ( 80 years old ) thanks a million
elcuco
13th May 2006, 19:35
boy you have better eyes then I do ( 80 years old ) thanks a million
You meant 80 years young dud... :p
impeteperry
14th May 2006, 01:34
Ain't ready to quit yet. Maybe I'll get it right next year.
Thanks to you and all your buddies @ Qt Centre.
nando76
29th January 2009, 07:36
Text entry widgets usually use QPalette::Base as the background color.
QPalette p = textEdit->palette();
p.setColor(QPalette::Base, QColor(240, 240, 255));
textEdit->setPalette(p);
How can i change the foreground (text) color of the QLineEdit ?
p.setColor(QPalette.WindowText, Qt::red)
...
doesn't work....
Greetings,
Nando
jpn
29th January 2009, 07:52
Try using QPalette::Text:
The foreground color used with Base. This is usually the same as the WindowText, in which case it must provide good contrast with Window and Base.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.