QGraphicsItem subclass item, doubleclickevent must doubleclick twice to select the item
-
-
GraphicsPolygonItem subclass of QGraphicsPolygonItem; GraphicsView subclass of QGraphicsView;
-
There are two GraphicsPolygonItem items(we call them item-A item-B) in the scene(GraphicsView hold the scene);
-
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 item.
-
I have debug it as, when I doubleclick the other item, it will not come into the GraphicsPolygonItem::mouseDoubleClickEvent(QGraphi csSceneMouseEvent *event). If I doubleclick twice, it will come into the function.
here is the code: //GraphicsPolygonItem
void GraphicsPolygonItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) { /*here doing some thing for select item......*/ //... QGraphicsPolygonItem::update(); QGraphicsPolygonItem::mouseDoubleClickEvent(event); }
//GraphicsView
void GraphicView::mouseDoubleClickEvent(QMouseEvent *event) { QGraphicsView::mouseDoubleClickEvent(event); }
Be expecting your response! Thanks!
-
-
-
GraphicsPolygonItem subclass of QGraphicsPolygonItem; GraphicsView subclass of QGraphicsView;
-
There are two GraphicsPolygonItem items(we call them item-A item-B) in the scene(GraphicsView hold the scene);
-
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 item.
-
I have debug it as, when I doubleclick the other item, it will not come into the GraphicsPolygonItem::mouseDoubleClickEvent(QGraphi csSceneMouseEvent *event). If I doubleclick twice, it will come into the function.
here is the code: //GraphicsPolygonItem
void GraphicsPolygonItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) { /*here doing some thing for select item......*/ //... QGraphicsPolygonItem::update(); QGraphicsPolygonItem::mouseDoubleClickEvent(event); }
//GraphicsView
void GraphicView::mouseDoubleClickEvent(QMouseEvent *event) { QGraphicsView::mouseDoubleClickEvent(event); }
Be expecting your response! Thanks!
@TK_HPU said in QGraphicsItem subclass item, doubleclickevent must doubleclick twice to select the item:
this->QGraphicsPolygonItem::update();
I'm not a C++ expert, but what is this intended to be/do? Don't you mean either
this->update();
orQGraphicsPolygonItem::update();
? -
-
@TK_HPU said in QGraphicsItem subclass item, doubleclickevent must doubleclick twice to select the item:
this->QGraphicsPolygonItem::update();
I'm not a C++ expert, but what is this intended to be/do? Don't you mean either
this->update();
orQGraphicsPolygonItem::update();
?@JonB or simply update() ... :)
-
@JonB or simply update() ... :)
@Christian-Ehrlicher
What willthis->QGraphicsPolygonItem::update();
do? I haven't seen athis->Class::function()
written before? -
@Christian-Ehrlicher
What willthis->QGraphicsPolygonItem::update();
do? I haven't seen athis->Class::function()
written before? -
@Christian-Ehrlicher
What willthis->QGraphicsPolygonItem::update();
do? I haven't seen athis->Class::function()
written before?@JonB said in QGraphicsItem subclass item, doubleclickevent must doubleclick twice to select the item:
What will this->QGraphicsPolygonItem::update(); do?
Exactly what is written - call the
QGraphicsPolygonItem::update
onthis
. Usually it's not needed to do calls over fully qualified names, though ... and as usualthis->
is superfluous, this isn't dependent lookup in template code.@TK_HPU, if I were to guess you do something odd in a part of the code that you haven't shown. From what you posted there doesn't seems to be any reason for this behavior. Post some more of your program - the stuff before
QGraphicsPolygonItem::update
. I'd imagine something to be wrong there (or thereabout), as currently from what you show you just delegate to the base class ...