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

前端 未结 1 1842
别跟我提以往
别跟我提以往 2021-02-13 23:57

Let\'s say I have a ListView of clickable delegate components (or GridView or Repeater). These delegate components need to emit a signal a

相关标签:
1条回答
  • 2021-02-14 00:16

    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.

    0 讨论(0)
提交回复
热议问题