通过 QStyle 设置 QScrollBar 样式
我尝试通过自定义 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现了问题所在。 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.