PDA

View Full Version : How to change some colors in a QPlainTextEdit



aarelovich
2nd June 2009, 22:32
Hi:

I'm creating one of those editors that provide the fonts and colors cutomization functionality. the editor uses as a basis the QPlainTextEdit Class. However I can't find in the documentation how to change the background color of the QPlainTextEdit and the color of the letters. I know these are defined by the OS but isn't there any way to modify them?

Thanks for any answers.

faldzip
2nd June 2009, 22:43
Use QPalette:


QPalette p = ui->plainTextEdit->palette();
p.setColor(QPalette::Base, Qt::red);
p.setColor(QPalette::Text, Qt::white);
ui->plainTextEdit->setPalette(p);

aarelovich
2nd June 2009, 23:18
Thank you so very much. I'll try that tomorrow.