QScrollBar上的样式表使滚动条的背景带有棋盘格图案吗? [英] Stylesheet on QScrollBar leaves background of scrollbar with checkerboard pattern?

查看:412
本文介绍了QScrollBar上的样式表使滚动条的背景带有棋盘格图案吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用样式表设置QScrollBar的样式时,背景颜色会变成方格,而不是纯色.

When I style my QScrollBar using a stylesheet, the background color is checkered instead of being solid.

QScrollBar:horizontal {
    background-color: grey;
}

如何使滚动条的背景变为纯色?

How do you make the background of the scrollbar a solid color?

推荐答案

您所说的背景"实际上是两个子元素add-pagesub-page.您需要在这些子元素上定义背景元素.

What you are referring to as "the background" is actually the two sub-elements add-page and sub-page. You need to define the background element on those sub-elements.

最简单的解决方案是将两者上的background都删除.然后它将继承您已经在QScrollBar上设置的背景颜色grey:

The simplest solution would be to remove the background on both. Then it would inherit the background color grey that you have already set on QScrollBar:

QScrollBar::add-page:horizontal, QScrollBar::sub-page:horizontal {
    background: none;
}

但是,如果需要,您可以根据自己的喜好分别设置样式:

But if desired, you could style each individually to your liking:

QScrollBar::sub-page:horizontal {
    background: red;
}

QScrollBar::add-page:horizontal {
    background: green;
}

不幸的是,从官方文档.

这篇关于QScrollBar上的样式表使滚动条的背景带有棋盘格图案吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆