Qt World Summit: Register Today!

Bug? In QML, listmodel.append(data) two items instead of listmodel.insert(0,data), only one item is shown??

  • I think the code snippet below is enough to demonstrate the bug I think I’ve found. If I have a ListModel in QML and I insert() two items at the beginning of the list, my ListView shows both items correctly. However, if I have an empty list and add two items to the end of the list using the append() command instead, only one item of the ListView appears, even through listmodel.count===2 and listview.count===2. I believe this error must be due to the same internal structure bug which is causing the crash I posted "here":http://qt-project.org/forums/viewthread/19477/.

        @ListModel {
            id: alertModel
        Component.onCompleted: {
            var data1 = {
                'alertDescription' : "Alert #1",
                'alertType' : 2,
                'acknowledged' : false,
                'alertState' : "yellow",
                'alertId' : 0
            var data2 = {
                'alertDescription' : "Alert #2",
                'alertType' : 3,
                'acknowledged' : false,
                'alertState' : "red",
                'alertId' : 1
    //        alertModel.insert(0, data1);
    //        alertModel.insert(0, data2);
            dropdown.state = "dropExpandedMultipleAlerts";   // make them visible
            dropDownButton.state = "expanded";

    I’m using Qt code 4.7.4, with the latest 4.7 updates. I know it’s not 4.8.1, but I’m choosing not to use that version because it crashes when qmlviewer.exe can’t find an exported C++ library, rather than gracefully refusing.

Log in to reply