Given a mouse position on click or double-click, what is the best way to identify a plottable's data point (key,value) that is beneath or nearest to the mouse position?
Given a mouse position on click or double-click, what is the best way to identify a plottable's data point (key,value) that is beneath or nearest to the mouse position?
use QCPGraph::pixelsToCoords method, you can easily get key and value of graph.
I can not get x/y axis data:
I make a connection:
connect(ui->widget,SIGNAL(mouseRelease(QMouseEvent*)),this,SLOT(clickedGraph(QMouseEvent*)));
Function:
clickedGraph(QMouseEvent* coord) { //how can i get x/y axis value for this coord? }
I solved:
double xx=ui->widget->xAxis->pixelToCoord(coord->x()); double yx=ui->widget->yAxis->pixelToCoord(coord->y());