Qt Reference Documentation

QML SelectionDialog Element

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

Inherits CommonDialog

  • List of all members, including inherited members
  • 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.

    Property Documentation

    delegate : Component

    Overrides the delegate component that visualizes the ListView model. The default delegate is MenuItem that shows a text string in the model data.

    read-onlymodel : 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. See QML Data Models documentation for more detailed information about the topic.

    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.

    selectedIndex : int

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