QScrollBar上的样式表使滚动条的背景带有棋盘格图案吗? [英] Stylesheet on QScrollBar leaves background of scrollbar with checkerboard pattern?
问题描述
当我使用样式表设置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-page
和sub-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屋!