LINUX.ORG.RU

Вызов функции делегата в ListView

 , ,


0

1

Есть модель, делегат и лист вью:

    function getList() {
        var ret;
        var i;
        for(i= 0; i < coefModel.count; i++) {
            var x = coefModel.get(i).val
            //ret.attach(x)
        }
        var d = coefModel.get(1).getVal
        console.log(d)
        return ret
    }

    ListView {
        id: listView0
        x: 112
        y: 117
        width: 354
        height: 80
        layoutDirection: Qt.RightToLeft
        orientation: ListView.Horizontal
        flickableDirection: Flickable.HorizontalFlick
        model: coefModel
        delegate: coefDelegate
        anchors.top: parent.top
        anchors.bottom: parent.bottom
        anchors.left: parent.left
        anchors.right: parent.right
    }

    Component {
        id: coefDelegate
        Coef {
            power: p
            val: v
        }
    }

    ListModel {
        id: coefModel
    }
Внутри Coef
    property int val: spinBox1.value

    function getVal() {
        return spinBox1.value
    }

Ни val, ни getVal() из coefModel.get(index) не работают. Как получить информацию от делегата?

Note: Delegates are instantiated as needed and may be destroyed at any time. They are parented to ListView's contentItem, not to the view itself. State should never be stored in a delegate.

Пиши свою модель.

fluorite ★★★★★
()
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.