QGraphicsItem select only border
-
Hello everyone,
I'm using a QGraphicsScene where I insert QGraphicsItems. I would like to know if it is possible to select only the edge of the object and not the whole object.
For example if I draw a rectangle I would like to have the possibility to select it only through the border is not inside it.
I'm using Qt5 on Windows.Thanks
-
Hi,
Yes it is, but you have to implement your own detection mechanism based on the mouse events..
-
Hello everyone,
I'm using a QGraphicsScene where I insert QGraphicsItems. I would like to know if it is possible to select only the edge of the object and not the whole object.
For example if I draw a rectangle I would like to have the possibility to select it only through the border is not inside it.
I'm using Qt5 on Windows.Thanks
@Gianluca86-0
reimplement QGraphicsItem::shape() by only returning the path only containing the border area you want to be selectable.
Then you can also use the selection capabilities of graphic items. -
Thanks @SGaist and @raven-worx , I try both methods to see which one to use better in my program.