Important: Please read the Qt Code of Conduct -

QML SceneGraph Custom Item- Each line with different color

  • Qt Champions 2017


    I'm using the SceneGraph to write graph. Sample graph is provided. I would like to draw different color for each line. UpdatePainteNode(...) code is given here. Is this possible. I have tried with vertiexcolor etc. Not able to do this.

    QSGNode *graph::updatePaintNode(QSGNode *oldNode, QQuickItem::UpdatePaintNodeData *)
        qDebug() << Q_FUNC_INFO << " Updating the node" <<endl;
        WaveForm *n= static_cast<WaveForm *>(oldNode);
        QRectF rect = boundingRect();
        if (!n) {
            n = new Graph();
            n->m_wave1 = new Node(this->m_maxPoints);
            m_waveForm = n;
        }else {
        return n;

  • @dheerendra said in QML SceneGraph Custom Item- Each line with different color:


    I think it's possible. I saw some this like this implemented to draw graphs with different colors.
    May be this may be of some help using 'QSGVertexColorMaterial ' & 'QSGFlatColorMaterial ' with flag 'QSGNode::OwnsMaterial'

    [](For Reference)

Log in to reply