QCustomPlot Discussion and Comments

How to drag a graph only horizontally (for "x" axis)Return to overview

Hello,

For the moment, for dragging I use:

ui->customPlot->setInteraction(QCP::iRangeDrag, true);

This will let me drag graph on both axes.
I want to use constant values for Y axis, so I did not want to be able to drag that.
Is any way I can disable drag on Y axis?

Thank you, Maria.

You'll need to call this function for each of the QCPAxisRect you want to apply this function :

setRangeDrag(Qt::Horizontal);

Ex:

foreach(QCPAxisRect *rect, ui->customPlot->axisRects())
     rect->setRangeDrag(Qt::Horizontal);

Thank you, this worked for me.