我在簡單的QSS(Qt樣式表)中有許多錯誤。是Qt的錯誤嗎?Qt樣式表錯誤?
實施例:
樣式表:
#check1 {
color: red //didn't work here
}
#check2 {
color: red; //but work here
background-color: black
}
#label1 {
color: blue;
text-decoration: underline //work fine here
}
#label2:hover {
color: blue;
text-decoration: underline //but didn't work here
}
來源:
#include <QtGui>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
app.setStyleSheet(" #check1 {color: red} \
#check2 {color: red; background-color: black} \
#label1 {color: blue; text-decoration: underline} \
#label2:hover {color: blue; text-decoration: underline}");
QWidget w; w.setFixedSize(120,130);
QCheckBox check1("checkbox1",&w);
check1.setObjectName("check1");
check1.move(10,0);
QCheckBox check2("checkbox1",&w);
check2.setObjectName("check2");
check2.move(10,30);
QLabel label1("label1", &w);
label1.setObjectName("label1");
label1.move(10,60);
QLabel label2("label2", &w);
label2.setObjectName("label2");
label2.move(10,90);
w.show();
return app.exec();
}
QT 4.7.3-3; arch linux; GNOME 3回退模式
但是顏色:藍色適用於:懸停仍然有效... – TheHorse
你說得對!這很奇怪,因爲根據他們的文檔,它不應該。然而,我從經驗中知道,改變下劃線不起作用,因爲我試圖去做你過去在這裏做的事。 – Chris
Qt 4.7 DOES支持懸停http://doc.qt.nokia.com/latest/stylesheet-syntax.html#pseudo-states – spraff