1

I have a set of rectangles provided by c++ backend, and I'd like to paint each of them on qml side with some extra decorations, colors opacity etc (respecting rectangles' positions and sizes).

I was hoping for some special kind of view which would accept a model containing all these rectangles and then would use them in delegates to define items' positions and sizes.

The best I was able to find is 'Canvas' which I may use to fulfill my needs, but maybe there is something more suitable?

Michał Walenciak
  • 4,257
  • 4
  • 33
  • 61

2 Answers2

2

You can try using listview delegate.

May be you can use QObjectList-based Model, as said in below link

https://doc.qt.io/qt-5/qtquick-modelviewsdata-cppmodels.html

In your c++ code expose the required data from rectangles using Q_PROPERTY

Pavan Chandaka
  • 11,671
  • 5
  • 26
  • 34
2

A Repeater can accept a model and instantiate your Rectangles at any size/position.

Repeater {
    model: rectangleModel    // Comes from C++

    delegate: Rectangle {
        x: model.x
        y: model.y
        width: model.width
        height: model.height
    }
}
JarMan
  • 7,589
  • 1
  • 10
  • 25