How to set background color of my QTextEdit?
Unsolved
General and Desktop
-
Hi,
I have QTextEdit object. I would like to change his background color to color, which my MainWindow has ( it is gray ). How can I do that?
I tried like this:
QPalette palette2 = textEdit->palette(); palette2.setColor(QPalette::Window,palette().color(QWidget::backgroundRole())); textEdit->setPalette(palette2);
-
Hi
It has to be the right role. QWidget::backgroundRole() is not used it seems.Try
QPalette p = ui->textEdit->palette(); p.setColor(QPalette::Base, Qt::red); // BG p.setColor(QPalette::Text, Qt::white); // (plain) TEXT ui->textEdit->setPalette(p);