tags:

views:

22

answers:

2

Hey,

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 like to use is here:

void SvgDisplayWidget::mouseReleaseEvent(QMouseEvent *event) {}

Thanks

+1  A: 

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.

teukkam
Thanks, but how to find out which SVG image it maps to?In SVG file there are id's for each image. I'd like to find out this id.I don't want to get x,y,width,height data from the svg file itself because this position could be different on the GUI if it was moved at runtime via matrix transformations.
yper
OK, I understand now what you're asking and it seems there is no easy solution, Qt doesn't provide that kind of lookup inside the SVG file it has rendered.
teukkam
A: 

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);
}
tibur
But that would not help you to find the ID of the id *inside* the SVG image... Sorry.
tibur