سؤال

I'm trying to fiddle a bit with a Qt example regarding 2D Graphics.

Basically it is a small diagram editor. In the example, the author explains that the tracknodes() function is used to update the line's endpoints, when the user drags a connected node into a different position.

This actually does not happen. After looking at the code, I have the feeling it's because there is no event being called after moving the node QGraphicItem, in order to update the link's rendering.

I figured I have to find out where and how the QGraphicItem's movement is handled in order to send a wasDropped signal (or something like that) to a slot that re-renders the link. Does this make sense?

I'm pretty new to Qt/C++ in general, so I don't have a very clear idea on how to achieve this, does anyone have any pointers he/she could share?

هل كانت مفيدة؟

المحلول

He seems to be using the QGraphicsItem::itemChange virtual function to call the tracknodes() function which draws the lines. ItemChange should be called every time a node is moved. It's called in other cases as well but he only uses it for tracking the movement of the QGraphicsItem.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top