Isso: I just noticed that before I saw your post, it was my fault, didnt have a look in the docu..
I didnt use the selectTest, but it still works perfect for me:
QCPItemLine *cursor = new QCPItemLine(plot);
connect(plot, SIGNAL(mouseMove(QMouseEvent*)), this, SLOT(showVals(QMouseEvent*)));
void plotter::showVals(QMouseEvent *event)
//for my "cursor"########
double mouseX = plot->xAxis->pixelToCoord(event->pos().x());
double startPos = plot->yAxis->pixelToCoord(0);
double endPos = plot->yAxis->pixelToCoord(plot->size()->height());
//for the graph values #####
for(int i=0; i<plot->graphCount(); ++i)
int index = plot->graph(i)->findBegin(mouseX);
double x = plot->graph(i)->dataMainKey(index);
double y = plot->graph(i)->dataMainValue(index);
if(mouseX >= 0)
qDebug() << index << "X:" << x << "Y:" << y;
qDebug() << index << "X:" << 0 << "Y:" << 0;
I had a look at the selectTest, but couldnt figure out how to use it...
And last question:
You see the if(mouseX >= 0) ..i have this that it doesnt show my vals at index 0 when I am in x<0 with my mouse (--> x=0; y=0 for the graph(i).
Maybe it sounds stupid, but how do i get this for the right side/last index of my graph(i)?
Thank you for all your help!!