Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QML SceneGraph Custom Item- Each line with different color


  • Qt Champions 2017

    Hi

    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.
    Scene_GraphImage.png

    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);
            n->appendChildNode(n->m_wave1);
            n->m_wave1->redraw(rect,data());
            m_waveForm = n;
        }else {
            n->m_wave1->redraw(rect,data());
        }
        return n;
    }


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

    tePaintNode(

    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'

    [https://doc.qt.io/qt-5/qsgflatcolormaterial.html#details](For Reference)


Log in to reply