QCustomPlot Discussion and Comments

point identificationReturn to overview

sir below i am pasting my code which is demo.exe stopped working and i am getting Qwidget postion not the X-axis and Y-axis of QCP promoted form in Qwidget .....

bool demo::eventFilter(QObject *target, QEvent *event)
{
if(target == ui->real && event->type() == QEvent::MouseButtonPress)
       {
          QMouseEvent *mic = static_cast<QMouseEvent*>(event);
           QCustomPlot *customPlot;
  qDebug()<<"pos="<<mic<<endl;
          qDebug()<<"pos="<<mic->pos()<<endl;
           qDebug()<<"pos X="<<mic->pos().x()<<endl;
           qDebug()<<"pos y="<<mic->pos().y()<<endl;
 qDebug()<<customPlot->xAxis->pixelToCoord(mic->pos().x())<< customPlot->yAxis->pixelToCoord(mic->pos().y());
}return false
}

output:

pos= QMouseEvent(MouseButtonPress, 1, 1, 0)
pos= QPoint(92,107)
pos X= 92
pos y= 107
Sir i dont know why the exe stopped working it is saying ...
and i used your mousepress hint but slot error is coming so i dropped that ...

You've just created a non-initialized pointer of a QCustomPlot in the line
QCustomPlot *customPlot;
and then go on using it. Please make yourself familiar with C++ programming before approaching larger projects with Qt and/or plotting. You need an existing instance of a class before accessing non-static member functions or variables. If you have a QCustomPlot instance on your form (main window), you should access it with

ui->[name of the QCustomPlot]->xAxis->pixelToCoord(mic->pos().x())

About the "slot error": That means you've misspelled the slot/signal name or parameter type.