Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

Forums

OverviewFelgo 3 Support (Qt 5) › Qt rest example and ListModel

Tagged: 

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #18567

    Nicola
    #18571

    Günther
    Felgo Team

    Hi Nicola,

    when using a ListPage, a default SimpleRow delegate is automatically set for the AppListView shown on the Page. The SimpleRow supports extracting model properties for the list entries automatically, but only for array type models. When using a ListModel the SimpleRow is not able to automatically parse the model to show the text and icon.

    This is expected behavior, and the solution to define a custom SimpleRow to manually set the properties is correct! 😉

    Best,
    Günther

     

    #18573

    Nicola

    I tryed with array:

    Item {
        id: dataModel
        property var dataClub: []
        function setModelData(type, name, icon, code) {
            var club = { "type": type, "text": name, "idclub": code }
            dataClub.push(club)
        }
    
        function clearData() {
    
        }
    
        function updateFromJson(parsedClubJson) {
        ....
    }

    and in the ListPage i set model: MySingleton.dataClub but i see empty rows

    #18577

    Günther
    Felgo Team

    This example works for me to show SimpleRow items with the specified text:

    import Felgo 3.0
    import QtQuick 2.9
    
    App {
      Navigation {
        id: navigation
    
        NavigationItem {
          title: qsTr("List")
          icon: IconType.list
    
          NavigationStack {
            ListPage {
              title: "List"
              model: dataModel.dataClub
            }
          }
        }
      }
    
      Component.onCompleted: dataModel.loadData()
    
      Item {
        id: dataModel
        property var dataClub: []
        function setModelData(type, name, icon, code) {
          var club = { "type": type, "text": name, "idclub": code }
          dataClub.push(club)
        }
    
        function loadData() {
          dataClub = []
          setModelData("Type", "Item 1", IconType.home, 1);
          setModelData("Type", "Item 2", IconType.star, 2);
          setModelData("Type", "Item 3", IconType.list, 3);
          setModelData("Type", "Item 4", IconType.anchor, 4);
          dataModel.dataClubChanged(); // manually trigger signal that array model was modified internally
        }
      }
    }
    

    Best,
    Günther

    #18580

    Nicola

    Perfect! I missed the trigger.

    Thanks

Viewing 5 posts - 1 through 5 (of 5 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded