Single selection dialog. More...
Inherits Item
This element was introduced in qt-components 4.7.
The SelectionDialog is a dialog that allows the user to select a single item from several list elements.
// Create a selection dialog with a title and list elements to choose from. SelectionDialog { id: singleSelectionDialog titleText: "Dialog Header #1" selectedIndex: 1 model: ListModel { ListElement { name: "ListTitle #1" } ListElement { name: "ListTitle #2" } ListElement { name: "ListTitle #3" } } }
As with all dialogs the visual parent property is used to specify which area of the screen is grayed out while the menu is opened. If no visual parent is set then it is determined automatically and falls back to the root item.
The dialog is opened via the open() call:
Button { text: "SingleSelection" onClicked: { singleSelectionDialog.open(); } }
The dialog is automatically accepted and closed once an item got selected by the user. The name of the selected ListElement from the model is queried through the selectedIndex property:
Text { anchors.centerIn: parent text: singleSelectionDialog.model.get(singleSelectionDialog.selectedIndex).name }
In order to allow the user to pick several items from a list a MultiSelectionDialog is used.
property ListModel model property int selectedIndex property Component delegate // Style API property Style platformStyle
See also Dialog and MultiSelectionDialog.
delegate : Component |
The delegate that is used in order to render the ListElements inside the ListView of the SelectionDialog. The SelectionDialog provides a default delegate that renders the ListElements according to the UI guidelines. The default delegate can be exchanged by a custom one.
model : ListModel |
The ListModel used for the contents of the dialog. The default is an empty list model. The names of the ListElements stored inside the model are displayed as items the user can choose from.
Property default is SelectionDialogStyle{}
Property for styling the component.
selectedIndex : int |
Returns the index of the ListElement selected by the user from the SelectionDialog. Property default is -1 (no selection). If the property is set during the declaration of the dialog then the preselected item is highlighted in order to suggest the default choice.
© 2008-2011 Nokia Corporation and/or its subsidiaries. Nokia, Qt and their respective logos are trademarks of Nokia Corporation in Finland and/or other countries worldwide.
All other trademarks are property of their respective owners. Privacy Policy
Licensees holding valid Qt Commercial licenses may use this document in accordance with the Qt Commercial License Agreement provided with the Software or, alternatively, in accordance with the terms contained in a written agreement between you and Nokia.
Alternatively, this document may be used under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation.