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. make a delegate from from a QQmlListProperty
Forum Updated to NodeBB v4.3 + New Features

make a delegate from from a QQmlListProperty

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 339 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.
  • C Offline
    C Offline
    cosmoff
    wrote on last edited by aha_1980
    #1

    Hello,

    I did a

    Q_PROPERTY ( QQmlListProperty<Sensor> sensorsList    READ sensorsList NOTIFY sensorsListChanged )
    

    and in the class Sensor I did :

    Q_PROPERTY ( QQmlListProperty<Data> parameterList READ parameterList NOTIFY parameterListChanged )
    

    So in my QML code I have :

    Column{
                    width: parent.width
    
                    ListView{
    
                        id:sensorList
                        width: parent.width
                        height: parent.height
                        model: m_sensor.sensorsList
                        clip: true
    
                        delegate: Sensor {
                            width: parent.width
                            height: 130
    
                            title: modelData.Name//It works !!!
                        }
                    }
                }
    

    in the Sensor.qml I have

    Row {
                width: 100
                spacing: spectroDetectionViewGI.technologyRowSpacing
    
                anchors {
                    top: parent.top
                    bottom: parent.bottom
                }
    
                ListView {
                    width: 50
                    model:  m_sensor.sensorsList.parameterList  // It doesn't work
    [...]
    

    Do you have an idea ?

    thanks

    KroMignonK 1 Reply Last reply
    0
    • C cosmoff

      Hello,

      I did a

      Q_PROPERTY ( QQmlListProperty<Sensor> sensorsList    READ sensorsList NOTIFY sensorsListChanged )
      

      and in the class Sensor I did :

      Q_PROPERTY ( QQmlListProperty<Data> parameterList READ parameterList NOTIFY parameterListChanged )
      

      So in my QML code I have :

      Column{
                      width: parent.width
      
                      ListView{
      
                          id:sensorList
                          width: parent.width
                          height: parent.height
                          model: m_sensor.sensorsList
                          clip: true
      
                          delegate: Sensor {
                              width: parent.width
                              height: 130
      
                              title: modelData.Name//It works !!!
                          }
                      }
                  }
      

      in the Sensor.qml I have

      Row {
                  width: 100
                  spacing: spectroDetectionViewGI.technologyRowSpacing
      
                  anchors {
                      top: parent.top
                      bottom: parent.bottom
                  }
      
                  ListView {
                      width: 50
                      model:  m_sensor.sensorsList.parameterList  // It doesn't work
      [...]
      

      Do you have an idea ?

      thanks

      KroMignonK Offline
      KroMignonK Offline
      KroMignon
      wrote on last edited by KroMignon
      #2

      @cosmoff No this cannot work!

      change your Sensor.qml to add something like this (I suppose it is based on Item)

      Item {
          [...]
          property alias model: __lv.model
          [...]
      
          ListView {
              id: __lv
          }
      
      }
      

      And then in you QML

      Column{
                      width: parent.width
      
                      ListView{
      
                          id:sensorList
                          width: parent.width
                          height: parent.height
                          model: m_sensor.sensorsList
                          clip: true
      
                          delegate: Sensor {
                              width: parent.width
                              height: 130
      
                              title: modelData.Name
                              model: modemData.parameterList 
                          }
                      }
                  }
      

      It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

      1 Reply Last reply
      1

      • Login

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