ComboBox

Provides a drop-down list functionality. More...

Inherits FocusScope

This type was introduced in QtQuick.Controls 1.0.

Properties

Detailed Description

Add items to the comboBox by assigning it a ListModel, or a list of strings to the model property.

ComboBox {
    width: 200
    model: [ "Banana", "Apple", "Coconut" ]
}

Example 2:

ComboBox {
    model: ListModel {
        id: cbItems
        ListElement { text: "Banana"; color: "Yellow" }
        ListElement { text: "Apple"; color: "Green" }
        ListElement { text: "Coconut"; color: "Brown" }
    }
    width: 200
    onCurrentIndexChanged: console.debug(currentText + ", " + cbItems.get(currentIndex).color)
}

You can create a custom appearance for a ComboBox by assigning a ComboBoxStyle.

Property Documentation

activeFocusOnPress : bool

This property specifies whether the combobox should gain active focus when pressed. The default value is false.


currentIndex : int

The index of the currently selected item in the ComboBox.


read-onlycurrentText : string

The text of the currently selected item in the ComboBox.


read-onlyhovered : bool

This property indicates whether the control is being hovered.


model : model

The model to populate the ComboBox from.


read-onlypressed : bool

This property holds whether the button is being pressed.


style : Component

The style Component for this control.

See also Qt Quick Controls Styles QML Types.


textRole : string

The model role used for populating the ComboBox.