QCustomPlot Discussion and Comments

postion identifierReturn to overview

If i click on any graph can i get X-axis and y-axis intersection point...
(mouse event on QWidget i tried not getting how to do)..please help me

It's been answered many times! see if this http://www.qcustomplot.com/index.php/support/forum/91 can help you!

how to use this method sir.please help me with small snippet (i am new to QCP so dont knw much about this)..

The pixelToCoord method takes pixel values in the reference frame of the QWidget and transforms it to axis coordinates (See QCustomPlot documentation).

So for example, if you react to a mouse click, you will get a QMouseEvent which provides you with the clicked x and y coordinates in pixels (see Qt documentation). Then you could transform the x pixels to xAxis coordinates via customPlot->xAxis->pixelToCoord(x). And the same with the y pixel value using the yAxis.

sir i am having

bool RealTime::eventFilter(QObject *target, QEvent *event)
    if(target == ui->real && event->type() == QEvent::MouseMove)
          QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
      return false;

mouseEvent object now how to print the values from mouseEvent object because it is not globally declared in my case so can tell me to print inside this function
if possible please modify my code tell me sir ...Thanks

guys please reply I started QCP i am through my task 90% work done only mousePress method i need to use and find out the postion of graph,i am fine doing in QTableWidget but with QCP only your blog has to answer me

I suggest using the signal mouseMove of QCustomPlot instead of an eventFilter. However, using the QMouseEvent is the same in both cases and was explained by me in my last post here. The QMouseEvent doesn't need to be globally declared, because in the slot were it is declared, you place code that shows the coordinates somewhere. What exactly this code needs to be depends on the way you wish to show the coordinates. You could for example just set the text of a QLabel on your main window accordingly.

If you just want to print it with qDebug(), you need to access the event->pos().x() and event->pos().y() coordinate and transform the pixels into axis coordinates with QCPAxis::pixelToCoord (see my last post). Then just output the result with qDebug().

Something like this:

qDebug() << customPlot->xAxis->pixelToCoord(mouseEvent->pos().x()) << customPlot->yAxis->pixelToCoord(mouseEvent->pos().y());