[Qt-interest] collisions with or picking edges of QGraphicsItem

lloyd konneker bootch at nc.rr.com
Sat Oct 29 01:46:44 CEST 2011


I want to detect when the pointer(cursor) collides with (hits) the edge
of a graphic item, distinct from when the cursor is inside a closed
polygon graphic item.

I tried hover, but it detects inside.  I tried item.collidesWithPath()
but it also detects inside.

>From the web, I surmise that I need to reimplement item.shape() and
return an open path?  (If I return a closed path, will it still detect
inside?)

(Or brush (fill) with transparent?)

Previously I did this using cairo, where there is an inStroke()
function, distinct from inFill().  In other words, it distinguished the
path from the fill, and distinguished the ideal path from the inked
path.  I am struggling to find similar concepts in Qt.

I am not yet worried about performance.  I suppose the advantage of
QGraphicsScheme collision detection (e.g. scheme.items()) is that it is
fast.  I suppose I can use it to find all items that intersect or
contain a region around the cursor, and pick from them using
item.collidesWithPath() calling my overridden item.shape().

I would appreciate hints or references.

I am porting to Qt from Gtk and Cairo because Qt is more portable and
provides a scheme object.






More information about the Qt-interest-old mailing list