QCustomPlot Discussion and Comments

How to draw line follow mouse moving?Return to overview

Hello everyone,
I'm writing a audio Editor. I use QCustomPlot to show the audio wave in a widget and I want that when mouse moves there's a line follow mouse track.
What can I do?

I just figured out this feature in my QCPGraph drawing.
In my situation, by following the Tutorials/User Interactions, I subclassed QCumstomPlot and reimplement the function mouseMoveEvent. Remember to call the method setMouseTracking(true).

my mouseMoveEvent is like
mouseMoveEvent(QMouseEvent * event){

///first detect your layout element and find out the layout element in which you want to draw a line
QCPLayoutElement * layout_ele = this->layoutElementAt( event->pos() );

// I use QItemStraightLine to draw a line
QItemStraightLine * line = new QItemStraightLine(this);
///set properties for the line



Hope it helps.

All MY Best,