Neel Basu
Neel Basu

Reputation: 12904

Multiple Model QML Map View

I have a model on C++ side which is based on AbstractListModel. The model have a set of locations through a role that is being shown in a MapView. Following is the minimal version of my code. markerModel: MarkerModel is defined on C++ side.

Map{
    MapItemView {
        model: markerModel
        delegate: markerDelegate
    }

    Component {
        id: markerDelegate

        MapQuickItem{
            anchorPoint: Qt.point(2.5, 2.5)
            coordinate: QtPositioning.coordinate(position.y, position.x)
            zoomLevel: 0
            sourceItem: Rectangle{
                ...
            }
        }
    }
}

The delegate actually draws points for each positions in the model. Now I want to have multiple such models.

  1. I can have an AbstractTableModel on C++ instead of AbstractListModel view will loop through its columns and call markerDelegate on each column. Or do the same with row.
  2. Have multiple models dynamically exposed to QML rendered on a single view with a single delegate markerDelegate

Which one of these is standard practice ? or feasible ? How to achieve any one of these ?

Upvotes: 4

Views: 1047

Answers (1)

alez
alez

Reputation: 69

You can store data for each model in container and load appropriate data to the model object

Upvotes: -2

Related Questions