Hi. I am trying to make a line in a multi axis plot. I made a window that look like this: http://www.imagebam.com/image/d7bfa5326590446.
Here is part of the code to see how i made this.
customPlot->plotLayout()->clear(); customPlot->plotLayout()->setRowSpacing(-25); axis1 = new QCPAxisRect(customPlot); //axis1 is private var customPlot->plotLayout()->addElement(0,0,axis1); axis1->axis(QCPAxis::atBottom)->setAutoTickLabels(false); QCPAxisRect *axis2 = new QCPAxisRect(customPlot); customPlot->plotLayout()->addElement(1,0,axis2); axis2->axis(QCPAxis::atBottom)->setAutoTickLabels(false); QCPAxisRect *axis3 = new QCPAxisRect(customPlot); customPlot->plotLayout()->addElement(2,0,axis3); axis3->axis(QCPAxis::atBottom)->setAutoTickLabels(false); QCPAxisRect *axis4 = new QCPAxisRect(customPlot); customPlot->plotLayout()->addElement(3,0,axis4); QCPGraph *Graph1 = customPlot->addGraph(axis1->axis(QCPAxis::atBottom), axis1->axis(QCPAxis::atLeft)); Graph1->setData(x, y1); Graph1-> QCPGraph *Graph2 = customPlot->addGraph(axis2->axis(QCPAxis::atBottom), axis2->axis(QCPAxis::atLeft)); Graph2->setData(x, y2); QCPGraph *Graph3 = customPlot->addGraph(axis3->axis(QCPAxis::atBottom), axis3->axis(QCPAxis::atLeft)); Graph3->setData(x, y3); QCPGraph *Graph4 = customPlot->addGraph(axis4->axis(QCPAxis::atBottom), axis4->axis(QCPAxis::atLeft)); Graph4->setData(x, y4);
So i try to make a vertical line through this four graphs following this thread: http://www.qcustomplot.com/index.php/support/forum/110
Here is the code i write to make this line
void MainWindow::mousePress(QMouseEvent* event) { QCustomPlot *customPlot=ui->custom; static QCPItemLine *vCursor; double x = axis1->axis(QCPAxis::atBottom)->pixelToCoord(event->pos().x()); vCursor = new QCPItemLine(customPlot); customPlot->addItem(vCursor); vCursor->start->setCoords( x, QCPRange::minRange); vCursor->end->setCoords( x, QCPRange::maxRange); customPlot->replot(); }
But in the application output i obtain "virtual QPointF QCPItemPosition::pixelPoint() const No axes defined"
Can any one help me. I only want to graph a vertical line through this four graphs.
Thanks.