Qt->QGraphicsView->QGraphicsItem resizing

泪湿孤枕 提交于 2019-12-22 08:53:53

问题


I'm pretty new to QGraphicsView in Qt.

As far as I can tell there is no built in way to resize a QGraphicsItem in a scene with a mouse.

What I'm looking for is to be able to resize a QGraphicsRectItem by either dragging out the corners or the edges on screen.

Is there a simple way to do that? Is there a library or a piece of code somewhere online that implements this functionality?

I'm currently using Qt 4.5.1.


回答1:


I guess this thread has a similar question. You will have to manually resize the item after intercepting the mousemove events. You can get the 'pos' from 'event' argument like:-

QPointF pt = event->pos()

Use this point 'pt' for resizing to the correct location.

Also lookup the 'Elastic Nodes' application in Qt Demos application. This will help.



来源:https://stackoverflow.com/questions/1072047/qt-qgraphicsview-qgraphicsitem-resizing

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!