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

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -