Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Bug? In QML, listmodel.append(data) two items instead of listmodel.insert(0,data), only one item is shown??
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved QML and Qt Quick
1 Posts 1 Posters 2.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    spazvt
    wrote on last edited by
    #1

    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);
            alertModel.append(data1);
            alertModel.append(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.

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved