英文:
Qt QScrollBar slider shadow
问题
你可以如何设置 QScrollBar 滑块的阴影,就像这样所需样式?从 QScrollBar 继承了一个类,配置了与图片中相似的 QStyleSheet,尝试添加 GraphicsEffect,但它被添加到整个 QScrollBar,而不是滑块。
英文:
How can I set the shadow to slider handle of a QScrollBar like this required style?
Inherited a class from QScrollBar, configured QStyleSheet as in the picture, tried to add a GraphicsEffect, but it is added to the whole QScrollBar, but not to the Slider
答案1
得分: 0
不确定是否有帮助,但您可以尝试以下方法,并在从子控件获取样式后应用您的 QGraphicsEffect
,甚至将正确的 painter
传递给 drawComplexControl
方法:
https://doc.qt.io/qt-5/qstyle.html#subControlRect
https://doc.qt.io/qt-5/qstyle.html#drawComplexControl
https://doc.qt.io/qt-5/qgraphicseffect.html#draw
我知道您可以访问滑块的 QRect,但不确定这是否能在您的探索中激发灵感。
QRect handleRect = style()->subControlRect(QStyle::CC_ScrollBar, &option, QStyle::SC_ScrollBarSlider, this);
英文:
Not sure if this helps, but you could try with the following methods and apply your QGraphicsEffect
after getting the style from the subcontrol, or even passing the right painter
to the method drawComplexControl
:
https://doc.qt.io/qt-5/qstyle.html#subControlRect
https://doc.qt.io/qt-5/qstyle.html#drawComplexControl
https://doc.qt.io/qt-5/qgraphicseffect.html#draw
I know that you can access to the QRect for the slider, but I don't know if this can inspire you in your quest.
QRect handleRect = style()->subControlRect(QStyle::CC_ScrollBar, &option, QStyle::SC_ScrollBarSlider, this);
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论