QCustomPlot Discussion and Comments

Axis tag mouse dragReturn to overview

Hello everyone,

I would like to drag axis tag with mouse, what would be steps to achieve that?

Example I am referring to is https://www.qcustomplot.com/index.php/tutorials/specialcases/axistags .

Thank you in advance!

Like all layerables, the items that are used in that example have the protected methods mousePressEvent, mouseMoveEvent and mouseReleaseEvent.
https://www.qcustomplot.com/documentation/classQCPLayerable.html#af6567604818db90f4fd52822f8bc8376

you can reimplement those methods and implement your dragging.

I think it should even be sufficient to first reimplement mousePressEvent and have it call event->accept() to communicate that you want to grab the mouse interaction (and receive the following move/release events).
In the mouseMoveEvent you now simply move your item according to the event->pos().

Ah and don't forget to call replot() in the move event :)

Thank's for helping out!!