View Full Version : QGraphicsItem subclass item, doubleclickevent must doubleclick twice to select

25th December 2019, 10:28
1. GraphicsPolygonItem subclass of QGraphicsPolygonItem; GraphicsView subclass of QGraphicsView;

2. There are two GraphicsPolygonItem items(we call them item-A item-B) in the scene(GraphicsView hold the scene);

3. I can doubleclick to select one item(item-A), but when I doubleclick the other(item-B), it doing nothing. But, I doubleclick item-B once again, item-B will be selected. It means I have to doubleclick twice to switch and select the other. Yes, it is switch and select, because if i only click item-A, it don't need doubleclick twice.

4. I have debug it as, when I doubleclick the other item, it will not come into the GraphicsPolygonItem::mouseDoubleClickEvent(QGraphi csSceneMouseEvent *event).

here is the code: //GraphicsPolygonItem

void GraphicsPolygonItem::mouseDoubleClickEvent(QGraphi csSceneMouseEvent *event)
/*here doing some thing for select item......*/
QGraphicsPolygonItem::mouseDoubleClickEvent(event) ;

void GraphicView::mouseDoubleClickEvent(QMouseEvent *event)

Be expecting your response! Thanks!