QSlider:在悬停时设置颜色

时间:2015-12-18 02:20:28

标签: qt

使用下面的样式表,目标是自定义QSlider,以便当鼠标悬停在滑块上时,滑块手柄和凹槽水平滑动线均为黄色。出于某种原因,我只能使滑块手柄变黄,但试图为凹槽着色会隐藏滑块手柄。如何解决这个问题?

QSlider styled with the stylesheet

        "QSlider {"
            "background-color: #FF3B3B3B;"
            "color: white;"
            "border : 0.1em;"
            "height:  1.5em;"
        "}"
        "QSlider::handle:vertical {"
            "height: 0.5em;"
        "}"
        "QSlider::groove:horizontal {"
            "height:  0 -0.7em;"
        "}"
        "QSlider:hover {"
            "border-color: yellow;"
            "background: #FF5A5A5A;"
        "}"

更改#1,添加此样式:

        "QSlider::handle:horizontal:hover {"
            "border: 4px solid #444;"
            "border-color: yellow;"
            "background: #FF5A5A5A;"
        "}"

更改#2,添加此样式:

        "QSlider::groove:horizontal:hover {"
            "border: 2px solid #444;"
            "border-color: yellow;"
        "}"

0 个答案:

没有答案
相关问题