Hello! The plot (QwtPlot) contains many markers (QwtPlotMarker). How to determine which marker was clicked?

To solve this problem, I changed the standard example of "event filter". After each click of the mouse, I check all the markers.
If the marker is located close to the click, this marker has been pressed.

Qt Code:
  1. void Plot::mousePressEvent(QMouseEvent *e)
  2. {
  3. QwtPlot::mousePressEvent(e);
  4.  
  5. const QwtPlotItemList& items = itemList();
  6. for ( QwtPlotItemIterator i = items.begin(); i != items.end(); ++i )
  7. {
  8. if ( (*i)->rtti() == QwtPlotItem::Rtti_PlotMarker )
  9. {
  10. QwtPlotMarker *m = static_cast<QwtPlotMarker*>(*i);
  11.  
  12. // The distance from the marker to the place a clicked
  13. float distance = sqrt( pow( (transform(QwtPlot::xBottom, m->value().x()) - e->pos().x()), 2 ) + pow( (transform(QwtPlot::yLeft, m->value().y()) - e->pos().y()), 2 ) );
  14.  
  15. if (distance <= 5)
  16. {
  17. qDebug() << "YEAP!";
  18. }
  19. }
  20. }
  21. }
To copy to clipboard, switch view to plain text mode 

Is there a better solution?