Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to bind the listview using listelement with dynamic values?
Forum Updated to NodeBB v4.3 + New Features

How to bind the listview using listelement with dynamic values?

Scheduled Pinned Locked Moved Unsolved General and Desktop
listviewlistmodmodel
2 Posts 2 Posters 843 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.
  • M Offline
    M Offline
    Mathan M
    wrote on last edited by
    #1

    Hi all,

    I want to bind the listelement from .cpp file. The code below is static. I have an .xml file with itemTitle,ImageURL,itemId and I can read from xml. Now I want to pass the value from .cpp to .qml

    Query:
    1.What is the return type has to mention in .cpp file to bind with list element?
    2. How to bind the return type in ListElement component in .qml file.

    If possible code snippet please.

    Code Snippet:

    ListElement { itemTitle: "Housing with Mortgages"; imageUrl: "qrc:/Samples/Maps/OpenExistingMap/Housing.png"; itemId: "2d6fa24b357d427f9c737774e7b0f977"}
    ListElement { itemTitle: "USA Tapestry Segmentation"; imageUrl: "qrc:/Samples/Maps/OpenExistingMap/Tapestry.png"; itemId: "01f052c8995e4b9e889d73c3e210ebe3"}
    ListElement { itemTitle: "Geology of United States"; imageUrl: "qrc:/Samples/Maps/OpenExistingMap/geology.jpg"; itemId: "74a8f6645ab44c4f82d537f1aa0e375d"}

    Thanks in advance.

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      @Mathan-M Why do you want to bind to ListElement?
      ListElement's are added to ListModel.
      You should probably try to access this model from C++. ListModel is also a QAbstractItemModel.

      157

      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