ListView.onAdd not being called



  • I have the following code (more or less) that I'm working with:

    @ListModel {
    id: tabModel
    ListElement {
    delegateText: "testing"
    }
    }

    Component {
    id: tabDelegate
    Item {
    id: delegateItem
    ListView.onAdd: SequentialAnimation {
    PropertyAction { target: delegateItem; property: "opacity"; value: 0 }
    NumberAnimation { target: delegateItem; property: "opacity"; to: 1, duration: 500; easing.type: Easing.InOutQuad }
    }
    Text {
    text: delegateText
    }
    }
    }

    ListView {
    id: tabList
    model: tabModel
    delegate: tabDelegate
    }

    function addTestElement() {
    tabModel.append({'delegateText': 'test'});
    }@

    When I dynamically add elements to the ListModel (e.g., using "addTestElement()"), they do get created, but the onAdd animation never occurs; the items simply appear, without a fade-in. What am I missing? Any help is greatly appreciated!

    (Also, I tried wrapping my code in at signs, but at least in the preview, it's still not getting syntax highlighting. I apologize!)



  • Try this:
    @
    SequentialAnimation {
    id: addAnim
    PropertyAction { target: delegateItem; property: "opacity"; value: 0 }
    NumberAnimation { target: delegateItem; property: "opacity"; to: 1, duration: 500; easing.type: Easing.InOutQuad }
    }
    .....
    ListView.onAdd: {
    addAnim.start()
    }
    @



  • I appreciate the help, but unfortunately that didn't seem to change anything. I'm looking at the example in examples/declarative/modelviews/listview , and that one works fine (I've just been using qmlviewer for all of this). I can't see what the difference between that and my code is yet, but I'll keep looking!



  • Odd, I just found "this thread":http://lists.qt.nokia.com/pipermail/qt-qml/2011-May/002577.html on the mailing list from a few months ago and after I commented out the width of the tabDelegate Component (not included in my minimal example above), the onAdd callback works as expected. But if the width is set, it doesn't fire. (I tested with a log statement.)

    Does anyone know why this would be so? Should I file a bug report?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.