Different delegates for QML ListView

前端 未结 6 845
自闭症患者
自闭症患者 2020-12-13 19:36

I would like to know if it\'s possible to use (several) different delegates for a QML ListView.

Depending on the individual object in the ListVie

6条回答
  •  再見小時候
    2020-12-13 19:59

    As far as you have only two types, the following code is as easy to maintain as easy to understand:

    delegate: Item {
        Employee { visible = position === "Engineer" }
        Manager { visible = position === "Manager" }
    }
    

    In case the number of types will grow, it is not a suitable solution for it easily leads to an hell of if statement.

提交回复
热议问题