Multiple Model Same delegate on QML MapView



  • 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 ?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.