Changing the color of a QFrame in QT

Gage Haas picture Gage Haas · Mar 13, 2018 · Viewed 13.3k times · Source

I have set the color of my main window in QT to be grey.

ui(new Ui ::MainWindow)
ui-> setupUi(this)
this->setStyleSheet("background-color: grey;");

I have tried multiple ways to set the color of the QFrame, however it takes on the default grey color that I have set. One way I tried is below.

ui->frame->setStyleSheet("color:rgb(255,255,255)");

I have tried to change the color of the QFrame by using the setStyleSheet method but no matter which color I assign it remains grey. I have tried setting the background, border, and color. Is there any way to do this that I am overlooking?

Answer

Nicholas Johnson picture Nicholas Johnson · Mar 13, 2018

You need to set the background color of the QFrame.

Set the QFrame's style sheet to the following:

"background-color: rgb(255, 255, 255);"