How to set background color of my QTextEdit?
Unsolved
General and Desktop
-
wrote on 7 Apr 2021, 13:19 last edited by
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,
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);
wrote on 7 Apr 2021, 15:25 last edited by@qwe3
I believe if you want to do it this way you have to set autoFillBackground.You don't have to do that if you use stylesheet instead.
-
1/3