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. [solved] ListView from a list variable

[solved] ListView from a list variable

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 2.0k Views
  • 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.
  • J Offline
    J Offline
    jech
    wrote on 26 Aug 2011, 17:11 last edited by
    #1

    Hi,

    I need to create a ListView which would contain items defined in a list variable. Lets say I have a variable called "fruits", which contains "orange", "apple", "pear" and "kiwi". Now I want to create a ListView which would contain Text items with these fruits. Of course I expect that if I change the variable "fruits" (delete "apple", for example), the ListView will change as well.

    I can do this using PySide, but this time I would like to stay with QML only, not requiring Python. How should I do this?

    Thank you.

    1 Reply Last reply
    0
    • T Offline
      T Offline
      task_struct
      wrote on 26 Aug 2011, 18:31 last edited by
      #2

      You can set ListView`s model to "ListModel":http://doc.trolltech.com/4.7/qml-listmodel.html . ListModel has functions for add/remove items from it. All changes are automaticaly updated in ListView.

      "Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program."

      • Linu...
      1 Reply Last reply
      0
      • J Offline
        J Offline
        jech
        wrote on 29 Aug 2011, 15:49 last edited by
        #3

        Thanks, this is what I needed!

        1 Reply Last reply
        0

        1/3

        26 Aug 2011, 17:11

        • Login

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