PDA

View Full Version : QPlainTextEdit selection color?



jajdoo
18th July 2010, 09:12
kind of a dumb question..

the default color of selected text (when dragging the mouse over text) is not to my liking (its almost invisible)
how can i change the default color?

tbscope
18th July 2010, 09:36
You can set a style sheet:


QTextEdit { selection-background-color: darkblue }

jajdoo
18th July 2010, 10:01
how can i do it from within the code?
( im really new to qt )

edit:
never mind, found it

Lykurg
18th July 2010, 10:39
You can use QWidget::setStyleSheet(). But for such a simple task I'd prefer using QPalette. Assuming textEdit is a pointer to your editor:
QPalette p = textEdit->palette();
p.setColor(QPalette::Highlight, QColor(/*what ever you want*/);
p.setColor(QPalette::HighlightedText, QColor(/*what ever you want*/);
textEdit->setPalette(p);