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. How to create multiple rectangles with Scene Graph?
Forum Updated to NodeBB v4.3 + New Features

How to create multiple rectangles with Scene Graph?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 332 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.
  • X Offline
    X Offline
    XEHXX
    wrote on last edited by
    #1

    I want to create a component with multiple rectangles and lines using QSG.These rectangles have different colors and text, should I create a node for each rectangle? but I don't know the upper limit for the number of rectangles.I want to show the part of the black border window in the image below, which can be panned and zoomed within the larger red border window, just like the map.
    alt text
    Now I've created a class "MAPNode" that inherits from QQuickItem.All rectangles belong to the QSGGeometryNode class.

    
    class MAPNode : public QSGNode
    {
    public:
        RectangleNode *rect;
        LineNode *line;
    };
    
    QSGNode *Graph::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *)
    {
    MAPNode *n= static_cast<MAPNode *>(oldNode);
    
     n->appendChildNode(n->rect);
     n->appendChildNode(n->line);
    }
    

    Can I put these rectangles in a QSGGeometryNode ?Or is there a better way to create this map?

    1 Reply Last reply
    0
    • GrecKoG Offline
      GrecKoG Offline
      GrecKo
      Qt Champions 2018
      wrote on last edited by
      #2

      You don't want to do that in QML ?
      That would be my advice. A Repeater with a Rectangle as delegate

      1 Reply Last reply
      0

      • Login

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