Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

make a delegate from from a QQmlListProperty



  • 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



  • @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 
                        }
                    }
                }
    

Log in to reply