如何在MFC视图中绘制QGraphicsItem
我开始在我的应用程序中使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
理论上,您可以使用 QGraphicsScene::paint 在缓冲区中使用 QGraphicsItems 来绘制场景,然后将其绘制到 MFC 视图,但这没有任何意义。 ?
QGraphicsView 到底有什么问题 您是否看过
rotate()
、scale()
、translate()
或shear()
它的功能是什么?Theoretically you could use
QGraphicsScene::paint
to paint the scene with yourQGraphicsItems
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 therotate()
,scale()
,translate()
orshear()
functions of it?您可以通过设置 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.