How to bind to a signal from a delegate component within a ListView in QML

心不动则不痛 提交于 2019-12-05 05:43:28

You could connect both signals in the Component.onCompleted handler.

Using your code it would be something like this:

ListView {
        id: myListView
        width: 100
        height: 600

        model: myModel
        delegate: TheDelegate {
            name: model.name
            Component.onCompleted: {
                trigger.connect(root.componentTriggered)
            }
        }
    }

Instead of calling the signal componentTriggered you could also implement a function, but it depends on your requirements. The signal is OK in any case.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!