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. Set a property of item in a DelegateModel
Forum Updated to NodeBB v4.3 + New Features

Set a property of item in a DelegateModel

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 564 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.
  • M Offline
    M Offline
    maxwell31
    wrote on last edited by
    #1

    Hi,

    I have a GridView which uses a DelegateModel as its model:

        GridView{
            model: DelegateModel{
                id: visualModel
                model: programModel
                delegate: ProgramButton {}
            }
        }
    

    How can I set a property of a delegate if I know its index?

    ODБOïO 1 Reply Last reply
    0
    • M maxwell31

      Hi,

      I have a GridView which uses a DelegateModel as its model:

          GridView{
              model: DelegateModel{
                  id: visualModel
                  model: programModel
                  delegate: ProgramButton {}
              }
          }
      

      How can I set a property of a delegate if I know its index?

      ODБOïO Offline
      ODБOïO Offline
      ODБOï
      wrote on last edited by
      #2

      @maxwell31 hi;

        model: DelegateModel{
                  id: visualModel
                  model: programModel
                  yourProperty : index===yourIndex ? propValue1 : propValue2
                  delegate: ProgramButton {}
              }
      
      1 Reply Last reply
      2
      • M Offline
        M Offline
        maxwell31
        wrote on last edited by
        #3

        Thanks for your answer. However, after some thinking I guess it was a poor design to even try to do that. I should change the model instead.

        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