在 QGraphicsRectItem 上绘制前景

发布于 2024-12-21 22:31:20 字数 214 浏览 3 评论 0原文

我需要一种方法让 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 技术交流群。

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

发布评论

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

评论(1

痴骨ら 2024-12-28 22:31:20

我不完全确定你想要做什么,但我怀疑你会遇到很大的悲伤,试图通过尝试让父项目的一部分绘制到其子项目上来对抗框架。也许您可以添加一个顶级子项,该子项位于覆盖有限区域的其他子项之上,并呈现与父项相同的内容并包含您想要的特殊覆盖线?

从图形视图中直接在场景上绘制也可能适合您的目的。

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.

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