【发布时间】:2015-05-06 08:24:07
【问题描述】:
我在我的 Qt Projets 中使用了一个 css 文件和 Visual Studio 2010。
main.cpp:
QApplication app(argc, argv);
// Mise en place du style CSS
QFile File("Resources/style.css");
File.open(QFile::ReadOnly);
QString styleSheet = File.readAll();
File.close();
app.setStyleSheet(styleSheet);
我的 css 文件的一部分:
QWidget#contenuDescription {
background-color: rgb(0, 150, 255);
border: 2px solid rgb(0, 0, 255);
border-top-left-radius: 10px;
border-top-right-radius: 10px;
border-bottom-right-radius: 10px;
border-bottom-left-radius: 10px;
}
QLabel#nom1 {
background-color: rgb(0, 150, 255);
font-size: 36px;
}
QLabel#nom2 {
background-color: rgb(0, 150, 255);
font-size: 24px;
}
QLabel#nom3 {
background-color: rgb(0, 150, 255);
font-size: 20px;
}
当bool m_changeColor == true 时,我想将颜色更改为我的 QLabel:nom1、nom2 和 nom3。
我知道如果我们想在鼠标位于 QLabel 上时更改样式表,我们可以使用::hover。我的问题是否存在这样的问题?
提前感谢您的回答。
【问题讨论】:
-
当你想改变颜色时,难道不能简单地向 css 添加更多类并更改标签的类吗?