QCustomPlot Discussion and Comments

Vertical Line on Mouse MovementReturn to overview

Hello, is there a way to draw a vertical line that follows the mouse movement within a qcustomplot? In addition, is it possible for this vertical line spans outside of it's axis / layout area? Thank you.

this is actually incredibly simple. on mouse move, you add a QCPItemLine, set its point positions in the y axis as 1 and 0 using ptAxisRectRatio and in the x direction you set them to your mouse point supplied by the event in ptAbsolute.

sorry, i misread the fact that you wanted it to span outside of axis area... for this you would use ptViewPortRatio instead of ptAxisRectRatio.

Thank you for the answer! Since i'm embedding 30+ qcustomplots widget in a scroll area, I wanted to minimize the number of vertical line drawn to one that spans across the screen.