Qt colliding selection boxes -
this app draws graphic items flags itemismovable , itemisselectable. qgraphicsview handles keyboard , mouse interaction.
i select smallest item in surface, if 2 boundingrects() collide; example, imagine 2 rectangles, 1 inside other. user clicking inside rectangle expect 1 selected.
my ideas :
(1) recalculate z-indexes each time item changes shape. seems little overkill.
(2) reimplementing qgraphicsitem.shape() [ items segment paths - if selection on segments , not on bounding box, work ] - returning qpainterpath() didn't seem trick.
(3) catch mouse events inside items first , (?) override default selection mechanism. seems overkill.
is there easy way achieve goal?
thanks, sébastien
when user selects item , graphics view receives position, can use position, convert scene coordinates , call qgraphicsscene::items function. return items @ given position.
now have list of items @ point user selected, can compare items find smallest , set selected.
Comments
Post a Comment