qtqmlqtquickcontrols2

Why does ComboBox popup customization reference delegateModel?


In the Qt QML documentation on customizing the Quick Controls 2 ComboBox, it shows:

popup: Popup {
    y: control.height - 1
    width: control.width
    implicitHeight: contentItem.implicitHeight
    padding: 1

    contentItem: ListView {
        clip: true
        implicitHeight: contentHeight
        model: control.popup.visible ? control.delegateModel : null
    ...

Why does it reference control.delegateModel instead of just control.model?

Where is this delegateModel property documented?


Solution

  • Delegates present the data items. A delegateModel combines the model and the prototypical delegate that will be instantiated for each item. Its key properties are model and delegate. The DelegateModel is an implementation of this concept provided in QtQml.Models.

    The delegateModel concept is an outgrowth of having the separate delegate and model properties. Eventually, more properties were added that always accompanied situations where both models and delegates were used, and instead of adding them directly to the control, they were encapsulated in a dedicated object.