Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How to set background color of my QTextEdit?
qwe3 last edited by
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);
JonB last edited by
You don't have to do that if you use stylesheet instead.
It has to be the right role. QWidget::backgroundRole() is not used it seems.
QPalette p = ui->textEdit->palette(); p.setColor(QPalette::Base, Qt::red); // BG p.setColor(QPalette::Text, Qt::white); // (plain) TEXT ui->textEdit->setPalette(p);