ui->setupUi(this);QCPLayoutGrid* layout = ui->customPlot->plotLayout();layout->clear();layout->setRowSpacing(0);layout->setColumnSpacing(0);QVector<double> x(101), y(101);for (int i = 0; i < 101; ++i) {x[i] = i / 50.0 - 1;y[i] = x[i] * x[i];}int count = 4;for (int i = 0; i < count; i++) {QCPAxisRect* axisRect = new QCPAxisRect(ui->customPlot);layout->addElement(i, 0, axisRect);if (i > 0 && i < count - 1) {axisRect->setMinimumMargins(QMargins(0, 0, 15, 0));}QCPAxis* xAxis = axisRect->axis(QCPAxis::atBottom);QCPAxis* yAxis = axisRect->axis(QCPAxis::atLeft);yAxis->setLabel(QString("曲线 %1").arg(i + 1));xAxis->grid()->setVisible(false);yAxis->grid()->setVisible(false);}QCPAxisRect* axisRect1 = qobject_cast<QCPAxisRect*>(layout->elementAt(0));QCPBars* volumePos = new QCPBars(axisRect1->axis(QCPAxis::atBottom), axisRect1->axis(QCPAxis::atLeft));volumePos->addData(x, y);volumePos->setPen(Qt::NoPen);volumePos->setBrush(QColor(100, 180, 110));QCPAxisRect* axisRect2 = qobject_cast<QCPAxisRect*>(layout->elementAt(1));QCPGraph* subGraphRandom = ui->customPlot->addGraph(axisRect2->axis(QCPAxis::atBottom), axisRect2->axis(QCPAxis::atLeft));subGraphRandom->addData(x, y);subGraphRandom->setPen(QPen(Qt::red, 4));ui->customPlot->replot();return;