我想为我的表单设置背景颜色
像这样
body
{
background-color: #fff;
}
我正在使用 QWidget 选择器,但我只想更改窗口背景;
我如何为所有窗口使用一个样式表?
最佳答案
您可以为任何QWdiget
设置特定的样式表。如果它是您的主窗口,您可以:
QString style = "QMainWindow { background-color: #fff; }"; // or other color
this->setStyleSheet(style); // assuming you are calling from the QMainWindow inherited class
您可以对主窗口中的单个小部件执行相同的操作,例如实例化为 label
的 QLabel
:
QString style = "QLabel { background-color: #fff; }"; // or other color
label->setStyleSheet(style);
您还可以定位另一个的所有子部件或指定单个子部件。看看http://doc.qt.io/archives/qt-4.7/stylesheet-examples.html
关于c++ - Qt Gui 应用程序背景颜色样式表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12026717/