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. Repeater Contextproperty Model not usable if Contextproperty index is used
Forum Updated to NodeBB v4.3 + New Features

Repeater Contextproperty Model not usable if Contextproperty index is used

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

    Hi,

    This works fine

     Repeater {
                id: rep
                model: deviceModel // <- QAbstractListModel
    
                delegate: BaseDevice {
                    dev: model // <- WORKS
                }
     }
    
    

    This doesnt, since model is not recognized anymore and can not be accessed during runtime

     Repeater {
                id: rep
                model: deviceModel // <- QAbstractListModel
    
                delegate: BaseDevice {
                    required property int index // <- BC OF THIS
                    dev: model // <- DOESNT WORK ANYMORE
                }
     }
    
    

    I know the functionality is exclusive, so either use index or model. Both achieve everything you need.
    But why does it behave like that?

    GrecKoG 1 Reply Last reply
    0
    • R Redman

      Hi,

      This works fine

       Repeater {
                  id: rep
                  model: deviceModel // <- QAbstractListModel
      
                  delegate: BaseDevice {
                      dev: model // <- WORKS
                  }
       }
      
      

      This doesnt, since model is not recognized anymore and can not be accessed during runtime

       Repeater {
                  id: rep
                  model: deviceModel // <- QAbstractListModel
      
                  delegate: BaseDevice {
                      required property int index // <- BC OF THIS
                      dev: model // <- DOESNT WORK ANYMORE
                  }
       }
      
      

      I know the functionality is exclusive, so either use index or model. Both achieve everything you need.
      But why does it behave like that?

      GrecKoG Offline
      GrecKoG Offline
      GrecKo
      Qt Champions 2018
      wrote on last edited by
      #2

      Because context properties are more ambiguous and have a less performant lookup. A decision was made that when using required properties context properties are disabled to avoid this overhead.

      1 Reply Last reply
      2
      • R Redman has marked this topic as solved on

      • Login

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