通过 QStyle 设置 QScrollBar 样式

发布于 2024-08-09 17:47:31 字数 188 浏览 6 评论 0原文

我尝试通过自定义 QStyle 设置 QScrollBar 的样式,但如果我在 QScrollBar 的 drawComplexControl 中不绘制任何内容,则父窗口小部件上滚动条所需的空间将被涂成黑色。如果我对 QToolButton 执行相同操作,则工具按钮不会被绘制,但小部件上没有黑色矩形。这就是我所期望的。 但是和QScrollBar有什么区别呢?

I try to style a QScrollBar via a custom QStyle but if i draw nothing in drawComplexControl for the QScrollBar, the required space for the scrollbar on the parent widget is painted black. If i do the same with, eg a QToolButton simply the toolbutton is not painted but there is no black rect on the widget. That is what i would expect.
But what's the difference to the QScrollBar?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

红ご颜醉 2024-08-16 17:47:31

我发现了问题所在。 QScrollBar 默认设置了 Qt::WA_OpaquePaintEvent 属性。如果重置,绘图的行为将与预期一致。

I figured out the problem. QScrollBar has Qt::WA_OpaquePaintEvent attribute set by default. If it is reset, drawing behaves like expected.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文