Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Creating Lists dynamically

    QML and Qt Quick
    3
    5
    4379
    Loading More Posts
    • 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
      sruthihsr last edited by

      Hi I want to create lists dynamically with names received from C++. Please let me know how to go about it

      1 Reply Last reply Reply Quote 0
      • R
        RazrFalcon last edited by

        You mean something like this:
        http://developer.qt.nokia.com/forums/viewthread/11330/P15/#62719
        ?

        1 Reply Last reply Reply Quote 0
        • S
          sruthihsr last edited by

          HI thanks for the reply.
          What i want is have a display dimensional form like below
          and the number of lists ie (Alist ,Blist,Clist is dynamic is realtime) and the items within the list a1,a2,a3 are also real time.
          Tell me how do I create them dynamically and access it in Qml.
          I am open to any approach
          Alist a1,a2,a3
          Blist b1,b2,b3
          Clist c1,c2

          1 Reply Last reply Reply Quote 0
          • D
            diro last edited by

            For dynamic list, there are many ways to archive it.

            1. http://doc.qt.nokia.com/latest/qml-qt.html#createQmlObject-method
            2. "http://cdumez.blogspot.com/2010/12/expose-nested-c-models-to-qml.html":http://cdumez.blogspot.com/2010/12/expose-nested-c-models-to-qml.html

            For dynamic item:
            @ListModel
            {
            id:vip_list;
            ListElement{name:"aaa";status:"invalid"; time:"2011-01-15..."}
            ListElement{name:"bbb";status:"invalid"; time:"2011-11-11..."}
            }@

            JS code:
            @vip_list.append({name:"ccc", status:"ok", time:"2011-01-01"});@

            For most case, you may combine the above with signal:
            JS code:
            @onDataReceived:
            {
            vip_list.append({name:PARAM1_FROM_SIGNAL, status:PARAM2_FROM_SIGNAL, time:PARAM3_FROM_SIGNAL});
            }@

            For access, you can try
            @vip_list.get(index).name
            vip_list.get(index).status
            vip_list.get(index).time@
            Please refer to "http://doc.qt.nokia.com/4.7-snapshot/qml-listmodel.html":http://doc.qt.nokia.com/4.7-snapshot/qml-listmodel.html

            1 Reply Last reply Reply Quote 0
            • S
              sruthihsr last edited by

              Hi, Hi,
              I have a situation where i have to display multiple lists corresponding to
              different parent.

              Alist A1 | A2| A3 | A4
              Blist B1 | B2| B3
              CList C1 | C2
              DList D1 | D2| D3 |D4

              The parents and the child elements i get are in different vectors.
              I will have to classify them into different lists based on the parent id and
              display them in qml.
              The number of parent elements and number of child elements are variable.

              I am able to do the appending through C++.

              suppose i create a master list which has lists in it

              @
              masterlist[0] ="A",list[A1 , A2, A3 , A4]
              masterlist[1] ="B",list[B1 , B2, B3 ]
              masterlist[2] ="C",list[C1 , C2 ]
              masterlist[3] ="D",list[D1 , D2, D3 , D4]
              @

              how do I access the list from my Qml like model :materlist.sublist.
              You can suggest any other approach

              [EDIT: code formatting, please wrap in @-tags, Volker]

              1 Reply Last reply Reply Quote 0
              • First post
                Last post