I have created a subclass of the QwtPlotPicker (aka MyPlotPicker) and overridden the trackerTextF() function because I want it to display more than X/Y values. In my trackerTextF() function, all I do for the moment is print out the function name to the terminal using cout.

While the application is running, when I press the left mouse button down, my functions name appears in the terminal four times -- but I only expected to it to appear once.

I am guessing that for some reason the trackerTextF() function is being called four times, but I cannot figure out why that would be so. Is this by design? One thing I did notice is that if I change the picker machine from Drag to Click, my trackerTextF() function only gets called twice.

Here is my code...

Qt Code:
  1. class MyOtherPicker: public QwtPlotPicker
  2. {
  3. public:
  4. MyOtherPicker(QwtPlotCanvas* pCanvas, Gui* pGui): QwtPlotPicker(QwtPlot::xBottom,
  5. QwtPlot::yLeft, QwtPlotPicker::CrossRubberBand, QwtPicker::ActiveOnly,
  6. pCanvas), mp_Gui(pGui)
  7. {
  8. setStateMachine(new QwtPickerClickPointMachine());
  9. setRubberBandPen(QColor(Qt::white));
  10. }
  12. protected:
  13. virtual QwtText trackerTextF(const QPointF &pos) const
  14. {
  15. cout << "trackerTextF" << endl;
  16. QwtText text;
  17. return text;
  18. }
  20. private:
  21. Gui* mp_Gui;
  22. };
To copy to clipboard, switch view to plain text mode