I have a gui which shows .svg file. When user clicks (or better when unclicks), the mouseReleaseEvent is called.
How do I find out which SVG image in particular (the ID) was clicked on?
I'd l开发者_StackOverflowike to use is here:
void SvgDisplayWidget::mouseReleaseEvent(QMouseEvent *event) {}
Thanks
I don't understand the question. You know which widget received the event in its mouseReleaseEvent
function, because it's the same widget where that code is executing. From there you can access all the data in that widget's implementation and it's up to you to find out which SVG image it maps to.
You can retrieve the topmost QGraphicsItem at a given position using the QGraphicsView::itemAt method.
void SvgView::mouseMoveEvent( QMouseEvent * event ){
QGraphicsItem* it = itemAt(event->pos());
if(it){
}
QGraphicsView::mouseMoveEvent(event);
}
精彩评论