Qt Reference Documentation

QML SelectionDialog Element

Represents a list of choices to the user. More...

Inherits CommonDialog

This element was introduced in Qt Quick Components 1.0.

Properties

Detailed Description

With SelectionDialog you can customize the visual representation of the selectable items' list by overriding the ListView delegate. By default SelectionDialog provides a scrollable list of textual menu items. The user can choose one item from the list at a time.

Using Data Models with SelectionDialog

The example below illustrates how to use the data models with the SelectionDialog. It has two dialogs that both allow the user to choose from three different items. Both dialogs use the default delegate. The first dialog uses a simple string list model and the second dialog uses a ListModel that contains one named role.

     SelectionDialog {
         id: dialog1
         titleText: "Select team:"
         model: ["Manchester United", "Barcelona", "Dynamo United"]
     }

     SelectionDialog {
         id: dialog2
         titleText: "Which one wins?"
         model: ListModel {
             ListElement { name: "Rock" }
             ListElement { name: "Paper" }
             ListElement { name: "Scissors" }
         }
     }

See also delegate.

Property Documentation

delegate : Component

Overrides the delegate component that visualizes the ListView model.


model : variant

The model that defines the selection dialog’s item list. The SelectionDialog uses it as a ListView component’s model in the dialog. The default delegate assumes that the model data is provided via the modelData role and interprets it as a text string. If you use a custom delegate, the model can be anything supported by QML ListView component.

Note: If the model contains only one named role, it is always provided via the modelData role. This also applies to a simple string list model. For more information, see QML Data Models documentation.


selectedIndex : int

Index of the currently selected item in the model. The default value is -1, which means that no item is selected.