Frank
Frank

Reputation: 2706

hoverevent on qwtplot in Qt

I have a qwtplot with a couple of qwtplotcurves attached to it. I want to have an event triggered when I hover one of the curves. I understood that I have to use installeventfilter() for this, but on what object should I use this? I cant use it on plot curve since this is not an object.

Upvotes: 1

Views: 1033

Answers (1)

c_k
c_k

Reputation: 1766

Please have a look at the event_filter which comes with Qwt. You should use the class CanvasPicker (it is not part of the Qwt API, but you'll find the code in the examples). You can instantiate it in your class using

    picker = new CanvasPicker(plot); // plot is a pointer to your instance of QwtPlot

You'll see that the event filter you refer to is installed in the constructor of CanvasPicker.

Now have a look at CanvasPicker::eventFilter(QObject *object, QEvent *e) which is called when an event occurs in the event loop of QwtPlot. Implement your application logic in the switch construct, f.i. change case QEvent::MouseMove:.

Upvotes: 2

Related Questions