如何在MFC视图中绘制QGraphicsItem

发布于 2024-09-01 07:02:08 字数 262 浏览 3 评论 0原文

我开始在我的应用程序中使用 Qt。我的应用程序是基于 MFC 的。我想在我当前的 MFC 视图中绘制一些 QGraphicsItems,这可能吗?

您可能会说,可以通过在 MFC 视图中使用 QWinWidget 托管 QGraphicsView 来完成,但这不起作用。因为我的Canvas(MFC视图)支持缩放和旋转,而QGraphicsView本身不支持。当我缩放 QGraphicsItem 时,QGraphicsView 显示滚动条而不是放大自身。

有什么建议吗?谢谢!

I'm starting using Qt in my application. My application is MFC based. I want to draw some QGraphicsItems in my currect MFC view, is it possible?

You may say that it could be done by hosting QGraphicsView with QWinWidget in the MFC view, that don't work, however. Because my Canvas (MFC view) supports zooming and rotating while the QGraphicsView itself don't. When I zooming the QGraphicsItem, the QGraphicsView shows scroll bar instead of enlarging itself.

Any suggestion? Thanks!

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

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

发布评论

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

评论(2

孤君无依 2024-09-08 07:02:08

理论上,您可以使用 QGraphicsScene::paint 在缓冲区中使用 QGraphicsItems 来绘制场景,然后将其绘制到 MFC 视图,但这没有任何意义。 ?

QGraphicsView 到底有什么问题 您是否看过 rotate()scale()translate()shear()它的功能是什么?

Theoretically you could use QGraphicsScene::paint to paint the scene with your QGraphicsItems in the buffer, and then draw it to MFC view, but it does not make any sense...

What is the problem with QGraphicsView anyway? Have you taken a look at the rotate(), scale(), translate() or shear() functions of it?

拿命拼未来 2024-09-08 07:02:08

您可以通过设置 ScrollBarPolcies< 来关闭 QGraphicsView 滚动条的显示/a> 到 Qt::ScrollBarAlwaysOff。 (QGraphicsView 是 QAbstractScrollArea 的子类。)

我不确定我是否理解旋转 QGraphicsView 本身而不是内容的意思。如果没有滚动条,我看不出有什么区别。此外,QGraphicsItem 的许多功能(如您所指示的编辑)取决于 QGraphicsScene 和 QGraphicsView 中的事件处理来工作。我认为仅将 QGraphicsItem 插入 MFC 视图不会满足您的要求。

You can turn off the displaying of scroll bard of QGraphicsView by setting the ScrollBarPolcies to Qt::ScrollBarAlwaysOff. (QGraphicsView is a sub-class of QAbstractScrollArea.)

I am not sure I understand what you mean by rotating QGraphicsView itself instead of the content. Without the scroll bars, I don't see the difference. Also much of the functionality of QGraphicsItem like editing as you indicated, depends on event handling in QGraphicsScene and QGraphicsView to work. I don't think plugging just a QGraphicsItem into the MFC view will do what you want.

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