API Documentation
Documentation for developing SailfishOS applicationsComboBox QML Type
A combo box control for selecting from a list of options More...
Import Statement: | import Sailfish.Silica 1.0 |
Inherits: |
Properties
- currentIndex : int
- currentItem : Item
- description : string
- label : string
- menu : Item
- value : string
Detailed Description
The ComboBox type provides a label with an attached menu to enable the user to select a value from a list of options.
A combo box displays a label together with a value. When the label or value is clicked, a context menu appears with a list of options, allowing the user to select a new value from this list. This context menu may be specified through the menu property.
Below is a simple combo box:
import QtQuick 2.2 import Sailfish.Silica 1.0 ComboBox { width: 480 label: "Screen brightness" menu: ContextMenu { MenuItem { text: "automatic" } MenuItem { text: "manual" } MenuItem { text: "high" } } }
The "Screen brightness:" label is displayed together with the value "automatic". When the label or value is clicked, the supplied menu appears, highlighting the currently selected option. When a menu item is clicked, the menu closes and the value updates to the new selection.
Notice the value property defaults to the text of the currently selected option. In the above example, the current selection defaults to the first item in the menu because neither currentIndex nor currentItem have been set.
See also BackgroundItem.
Property Documentation
The index of the item currently selected in the menu. This value defaults to 0.
Changing this value automatically updates the currentItem to refer to the item at this index. Setting this to an index outside of the range of options in the menu will clear the current selection, setting currentIndex to -1 and currentItem to null
.
If both currentIndex and currentItem are initially set, the currentItem value takes precedence.
See also currentItem.
The item currently selected in the menu. If currentIndex is set to a valid index, this defaults to the item referred to by currentIndex; otherwise, this defaults to null
.
Changing this value automatically updates the currentIndex to refer to the index of this item. Setting this to null
or an item with a false
value for enabled will clear the current selection, setting currentItem to null
and currentIndex to -1.
If both currentIndex and currentItem are initially set, the currentItem value takes precedence.
See also currentIndex.
The text of the currently selected menu option, as specified by currentIndex or currentItem.
See also label.