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. Is it possible to pass ListModel to ListView with some missing parameters?

Is it possible to pass ListModel to ListView with some missing parameters?

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 4 Posters 2.5k 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.
  • A Offline
    A Offline
    aabc
    wrote on 10 Jul 2011, 11:39 last edited by
    #1

    Is it possible to pass ListModel to ListView with some missing parameters?
    Is there a way to write a delegate that uses only the parameters that the model gave it and use default parameters for those who dont?

    1 Reply Last reply
    0
    • T Offline
      T Offline
      thisisbhaskar
      wrote on 11 Jul 2011, 04:36 last edited by
      #2

      Did you try this out ?? what is the problem you are facing...

      1 Reply Last reply
      0
      • H Offline
        H Offline
        h3nk3
        wrote on 11 Jul 2011, 06:19 last edited by
        #3

        You should be able to set default parameters in your delegate. So when parameters in your ListModel is not set the delegate shows what you deem to be the default value for them.

        1 Reply Last reply
        0
        • N Offline
          N Offline
          ngocketit
          wrote on 11 Jul 2011, 09:53 last edited by
          #4

          [quote author="aabc" date="1310297954"]Is it possible to pass ListModel to ListView with some missing parameters?
          Is there a way to write a delegate that uses only the parameters that the model gave it and use default parameters for those who dont?[/quote]

          Yes, you totally can do that. Check the sample below:

          @ListModel {
          ListElement {
          label: QT_TR_NOOP("Item 1")
          value: "item1"
          }
          ListElement {
          label: QT_TR_NOOP("Item 2")
          value: "item2"
          position: "left"
          disabled: "true"
          }
          }@
          Then in the delegate:

          @Item {
          state: (typeof model.disabled != "undefined" && model.disabled == "true" ? "disabled" : "")
          anchors.centerIn: (typeof model.position == "undefined" || model.position == "left" : leftContainer ? rightContainer);
          }@

          1 Reply Last reply
          0

          3/4

          11 Jul 2011, 06:19

          • Login

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