Install Event Filter instead of PlotPanner
Hey!
I had been trying to modify QwtPlotPanner to repaint plot canvas during panning, until I read that this is impossible and I should install an event filter instead, which would catch mouse clicks and repaint the plot using setAxisScale(). I did this, but I the event filter is not called. My code is like the following:
Code:
{
...
createAxes();
createLegend();
installEventFilter(m_eventFilter);
...
installPlotZoomer();
installPlotPicker();
}
where event filter is the following short calss:
Code:
class MyEventFilter
: public QObject{
protected:
std::cout << "MyEventFilter::eventFilter()" << std::endl;
return true;
}
};
MyEventFilter is not called. Any ideas why not?
Thank you in advance!
Re: Install Event Filter instead of PlotPanner
I think you probably need to install the event filter on the canvas, not the plot.
I think that in general, event filters are not stand-alone QObject classes, but are implemented as part of another class, in your case the Plot class. Try making your eventFilter() method a member of Plot. (Note that I am not sure of this, but if you look at the example under QObject::eventFilter(), that's how it is done there).
Besides, how do you know that your event filter isn't being called? Because you don't see anything on std::cout? Because of the potential for buffering and flushing in use of cout, I don't think that is very reliable. Either set a breakpoint inside you event filter and see what happens in the debugger, or use qDebug() instead of std::cout.
Re: Install Event Filter instead of PlotPanner
Quote:
Originally Posted by
missoni
I had been trying to modify QwtPlotPanner to repaint plot canvas during panning, ...
There are reasons why it is not implemented this way and as long as you don't have a plot where all scales are hidden you are wasting your time.
Uwe