QML:如何从信号中发送列表/数组?

3

我该如何创建一个能够发送包含数据数组(数字数组)信号的项,并从另一个项中读取这些数据?

1个回答

3
我不知道您具体想做什么,但这里有一个例子:

我不知道您具体想做什么,但这里有一个例子:

import QtQuick 1.0

Item {
    // item with the data
    Item {
        id: otherItem
        property variant numbers: [11, 22, 33]
    }

    // declare signal
    signal mySignal(variant array);

    // send mySignal when component is ready
    Component.onCompleted: mySignal(otherItem.numbers);

    // signal handler
    onMySignal: console.log("mySignal: " + array)
}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接