How to create multiple rectangles with Scene Graph?
Unsolved
QML and Qt Quick
-
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.
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?
-
You don't want to do that in QML ?
That would be my advice. ARepeater
with aRectangle
as delegate