0

Here is my problem and I totally want an advice, it will be helpful to me.

I want to add two items in my plot (for example two svg items). The first item is ID1, and the second item is ID2.

When I click the first svg item it should emit a signal. Similarly, when I click the second svg item it should emit another signal. But I dont want to use coordinates of items.

My aim is this, items must say to me their IDs when I click on them. **But I don't want to use coordinates of items. I can not figure it out how, please give me an advise.

Regards.

DYangu
  • 611
  • 1
  • 7
  • 16
alperyazir
  • 203
  • 1
  • 4
  • 14

1 Answers1

1

I'm afraid there is no way to do this without dealing with coordinates, since QwtPlotItem processes only paint events. Qwt doesn't route mouse events to items, so you need to implement this behavior manually.

  • Install an event filter on plot's canvas() and intercept mouse events.
  • Use QwtPlot::invTransform to convert mouse coordinates to values corresponding to x and y axes.
  • Iterate over QwtPlot::itemList and check if each item's QwtPlotItem::boundingRect contains clicked point.
Pavel Strakhov
  • 39,123
  • 5
  • 88
  • 127
  • Thank you for your answer. Currently I am using the method which is same technique as your answer. I am drawing those items with respect to datas in xml files. I mean coordinates are changing randomly. So i think i should draw without coordinates. And my brain stops in this point. – alperyazir Jan 16 '14 at 13:39