????????最近需要用到這個庫顯示數據,需要在一個曲線圖4個Y軸共用一個X軸,并且做游標,跟隨鼠標移動,并且實時反饋數據到表格中。記錄一下程序。
customPlot = new QCustomPlot(this);
customPlot->setBackground(QBrush(QColor(204,204,204,255)));
customPlot->setGeometry(30,50,870,350);
customPlot->installEventFilter(this);customPlot->yAxis->setRange(0,1000);customPlot->yAxis->setLabel("mm");QCPAxis *yAxisLeft1 = customPlot->axisRect()->addAxis(QCPAxis::atLeft);yAxisLeft1->setLabel("bar");yAxisLeft1->setRange(0,2500);yAxisLeft1->setTickLabels(true); QCPAxis *yAxisRight1 = customPlot->axisRect()->addAxis(QCPAxis::atRight);yAxisRight1->setLabel("m/s");yAxisRight1->setRange(0,10);QCPAxis *yAxisRight2 = new QCPAxis(customPlot->axisRect(), QCPAxis::atRight);yAxisRight2->setLabel("%");customPlot->axisRect()->addAxis(QCPAxis::atRight, yAxisRight2);yAxisRight2->setTickLabels(true);//yAxisRight2->setTickLabelRotation(90);yAxisRight2->setRange(0,100);customPlot->legend->setFillOrder(QCPLayoutGrid::foColumnsFirst);customPlot->legend->setWrap(5);customPlot->legend->setVisible(true);customPlot->plotLayout()->insertRow(0);customPlot->plotLayout()->addElement(0 , 0, customPlot->legend);customPlot->plotLayout()->setRowStretchFactor(1, 8);customPlot->legend->setBorderPen(Qt::NoPen);customPlot->legend->setBrush(Qt::NoBrush); line1 = new QCPItemStraightLine(customPlot);line1->setLayer("overlay");line1->setPen(QPen(Qt::gray, 1, Qt::DashLine));line1->setClipToAxisRect(true);line1->point1->setCoords(0, 0);line1->point2->setCoords(0, 0);line2 = new QCPItemStraightLine(customPlot);line2->setLayer("overlay");line2->setPen(QPen(Qt::gray, 1, Qt::DashLine));line2->setClipToAxisRect(true);line2->point1->setCoords(0, 0);line2->point2->setCoords(0, 0);