So I am trying to change only the background color of my MainWindow
. When I try to do this using this->setStyleSheet("background-color:black;");
for example it changes the background of everything: child widgets, QTextBoxEdit
background, everything.
Is there a way to only change the background of just the main window?
As you know, every QMainWindow
has a central widget and by default is named centralwidget
.
So the best way of solving this issue is changing the background for that widget.
It's pretty simple when we use a style sheet. In this case would be the following one:
#centralwidget {
background-color: rgb(0, 0, 0);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With