QCustomPlot Discussion and Comments

I want to draw lsimpulse. The color can be customized for each lineReturn to overview

I want to draw lsimpulse. The color can be customized for each line. I change how to modify the code. Here are some of my code.

    QVector<DataType> *coreData()
    {
        return &mData;
    }

    QVector<QCPGraphData> *mData;
    mData = this->graph(0)->data()->coreData();
    mData->clear();
    QCPGraphData newPoint;
    for (int i = 0; i < nIndex + dataCount; i++)
    {
        newPoint.key = m_start + i * m_dStep;
        newPoint.value = pdata[i];
        newPoint.color = QColor(255, 0, 0); //  This is extra  added ,It's not used

        qDebug() << "1" << newPoint.key << newPoint.value << newPoint.color.rgb();

        mData->append(newPoint);
    }
    this->replot();


void QCPGraph::drawImpulsePlot(QCPPainter *painter, const QVector<QPointF> &lines) const
{
    if (painter->pen().style() != Qt::NoPen && painter->pen().color().alpha() != 0)
    {
        applyDefaultAntialiasingHint(painter);
        QPen oldPen = painter->pen();
        QPen newPen = painter->pen();
        newPen.setCapStyle(Qt::FlatCap); // so impulse line doesn't reach beyond zero-line
        painter->setPen(newPen);
        painter->drawLines(lines);
        painter->setPen(oldPen);
    }
}

modify
void QCPGraph::drawImpulsePlot(QCPPainter *painter, const QVector<QPointF> &lines) const
{
    if (painter->pen().style() != Qt::NoPen && painter->pen().color().alpha() != 0)
    {
        applyDefaultAntialiasingHint(painter);
        QPen oldPen = painter->pen();
        QPen newPen = painter->pen();
        newPen.setCapStyle(Qt::FlatCap); // so impulse line doesn't reach beyond zero-line
        for(int i = 0; i < lines.size() / 2; i++)
        {
            newPen.setColor(QColor(qrand() % 255, qrand() % 255, qrand() % 255));
            painter->setPen(newPen);
            painter->drawLine(lines.at(i * 2), lines.at(i * 2 + 1));
        }
        painter->setPen(oldPen);
    }
}

newPen.setColor How to transfer the value of setColor

effect:
https://imgchr.com/i/yPTcX8

what's the question?