ComboBox with many items (Countries)
-
Over a hundred countries in a ComboBox element will create a slow and insanely big list when the dropdown is opened. Hot to show only 5 items in the list with a scrollbar?
And as a bonus: how to make the ComboBox editable? So the user can select a country by typing?
-
Please see "setMaxVisibleItems(int maxItems)":http://qt-project.org/doc/qt-5.0/qtwidgets/qcombobox.html#maxVisibleItems-prop and "setEditable(bool editable)":http://qt-project.org/doc/qt-5.0/qtwidgets/qcombobox.html#editable-prop methods
-
Uhmm I am not using the Widget in QML
-
sorry, didn't see that you want it in qml. Did you see that: "example":http://qt.gitorious.org/qt-components/qt-components/source/55b123e52c9975e089c1d936e0b05467779dd00e:ComboBox.qml ?
i mean this parts of code:
@
...
property int elementsToShow: 5;
...
Item {
...
height: Math.min(background.height * elements.count,
background.height * combobox.elementsToShow);
//for combobox size
....
Keys.onPressed: {
... //for selecting by typing
}
}
@ -
This is qt-components code not official Qt code?