Qt->QGraphicsView->QGraphicsItem resizing

2019-05-10 01:12发布

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.

标签: c++ qt qt4
1条回答
做个烂人
2楼-- · 2019-05-10 02:05

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.

查看更多
登录 后发表回答