How to set QPlainTextEdit text background color?
-
wrote on 8 Jul 2016, 05:30 last edited by Violet Giraffe 7 Aug 2016, 05:33
I've tried
setStyleSheet
with"background-color: #rrggbb"
, it does the trick, but it also affects scrollbars. How to set just the text bg color? -
I've tried
setStyleSheet
with"background-color: #rrggbb"
, it does the trick, but it also affects scrollbars. How to set just the text bg color?wrote on 8 Jul 2016, 05:48 last edited byHi!
QPalette p = ui->plainTextEdit->palette(); p.setColor(QPalette::Active, QPalette::Base, Qt::black); ui->plainTextEdit->setPalette(p); ui->plainTextEdit->setBackgroundVisible(false);
-
I've tried
setStyleSheet
with"background-color: #rrggbb"
, it does the trick, but it also affects scrollbars. How to set just the text bg color?wrote on 8 Jul 2016, 08:20 last edited byIf you want to change only the color of the entire viewport background (except scrollbar), must specify a selector.
like this:
ui->plainTextEdit->setStyleSheet("QPlainTextEdit {background-color: #rrggbb;}")
And if you want to set only the text background color,
like this:
QTextCharFormat fmt; fmt.setBackground(QBrush(Qt::yellow)); ui->plainTextEdit->mergeCurrentCharFormat(fmt);
-
If you want to change only the color of the entire viewport background (except scrollbar), must specify a selector.
like this:
ui->plainTextEdit->setStyleSheet("QPlainTextEdit {background-color: #rrggbb;}")
And if you want to set only the text background color,
like this:
QTextCharFormat fmt; fmt.setBackground(QBrush(Qt::yellow)); ui->plainTextEdit->mergeCurrentCharFormat(fmt);
wrote on 8 Jul 2016, 16:08 last edited by
1/4