[Interest] Is there a way to get QGraphicsScene's items at some position if they flagged as ItemIgnoresTransformations?

Dmitrii Volosnykh dmitrii.volosnykh at gmail.com
Mon Jan 27 19:29:50 CET 2014


Hi,

I create several circles and while dragging one of them I'd like it to snap
to the position of the other. This works O'kay when scene is viewed with
default zoom.

When I zoom out circles, do not change in size because they ignore
transformations (apparently the increase in size with respect to the
scene's coordinate system). Unfortunately, circle being moved snaps only
when it is positioned tightly close to the very center of another one, but
not when the mouse crosses its bounds. I believe that snapping feature is
working, but the tolerance distance is scaled down to very small value.

At first, I was finding the closest circle to mouse position and compared
it to the radius of the circle.
Then, I tried to use QGraphicsScene::items() to pick the list of circles
under mouse, but with no luck.

Contrary to this, items receive hover enter & leave events when needed. So
QGraphicsScene is able to determine what I want. So, I decided to browse
the sources and have digged down
to QGraphicsSceneIndexPrivate::recursive_items_helper() which is unclear to
me.

Is there a convenient way to achive the goal?

Regards,
Dmitrii.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20140127/733cb718/attachment.html>


More information about the Interest mailing list