在 QGraphicsRectItem 上绘制前景
我需要一种方法让 QGraphicsRectItem 在其子项之上进行绘制。我有一个包含多个子项目的项目。在特定高度,我需要在子项目上画一条线。
有没有办法在QGraphicsItems
中实现类似于QGraphicsScene
中的drawForeground
?
如果可能的话,我宁愿不必为每个子项目划线。
I need a way for a QGraphicsRectItem
to draw on top of its children. I have a item that contains several children items. At a specific height I need to draw a line over the child items.
Is there a way to implement a drawForeground
in a QGraphicsItems
similar to the drawForeground
in QGraphicsScene
?
If at all possible I would prefer to not have to draw the line for each child item.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不完全确定你想要做什么,但我怀疑你会遇到很大的悲伤,试图通过尝试让父项目的一部分绘制到其子项目上来对抗框架。也许您可以添加一个顶级子项,该子项位于覆盖有限区域的其他子项之上,并呈现与父项相同的内容并包含您想要的特殊覆盖线?
从图形视图中直接在场景上绘制也可能适合您的目的。
I'm not entirely sure what you are trying to do but I suspect you will encounter a great deal of grief trying to fight the framework by trying to make a part of the parent draw over its child items. Perhaps you can add a top level child that is over the other child items covering a limited area, and renders the same content as the parent and includes the special overlay lines you want?
It might also suit your purpose to draw right over the scene from the graphics view.