Qt样式表错误?

The*_*rse 13 user-interface qt styles stylesheet

我在简单的QSS(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
}
Run Code Online (Sandbox Code Playgroud)

资料来源:

#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();
}
Run Code Online (Sandbox Code Playgroud)

qt 4.7.3-3; arch linux; gnome 3后备模式

ale*_*sdm 8

对于第一个复选框,问题出现在Gtk +样式中: 在此输入图像描述

QLabel,QPushButton或者QCheckBox不支持伪状态css选择器text-decoration中的字体更改(包括):hover.最简单的小部件似乎是QToolButton(如果你真的需要它可以用来替换QLabel).
所有小部件都支持该状态的调色板更改(前景色和背景色和样式).