Nominate our 2022 Qt Champions!

Changing model root in a Package of a DelegateModel

  • I am working with hierarchical data in Qabstractitemmodel in QML within a Delegate model and Package component in order to allow me to display a list and then details on an item.

        DelegateModel {
            id: delegateModel
            model: myModel
            delegate: Package {
                GridDelegate {
                    onClicked: {
                        details.root = gridview.model.modelIndex(index)
                DetailsDelegate {

    The issue is that now that the delegate is in a Package component gridview.model is now a QqmlPartsModel and I get Property 'modelIndex' of object QQmlPartsModel(0xd75fa0) is not a function

    Qt example:

    Is there another way I should be going about this.

Log in to reply