Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QML SceneGraph Custom Item- Each line with different color
Qt 6.11 is out! See what's new in the release blog

QML SceneGraph Custom Item- Each line with different color

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 395 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • dheerendraD Offline
    dheerendraD Offline
    dheerendra
    Moderators Qt Champions 2024 Qt Champions 2022 Qt Champions 2017
    wrote on last edited by dheerendra
    #1

    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
    @Community Service
    Certified Qt Specialist
    https://www.pthinks.com

    1 Reply Last reply
    0
    • J Offline
      J Offline
      jay1
      wrote on last edited by jay1
      #2

      @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)

      1 Reply Last reply
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved