PDA

View Full Version : QML Combobox with QStringListModel



volcano
23rd November 2016, 11:36
I have a QStringListModel which is configured using the setStringList method.

I'm trying to use this model in QML Combobox. And I have exposed this model to qml using setContextProperty but I can't find the role name to be used in QML

I can't find a way to do so.

Please suggest.

anda_skoa
23rd November 2016, 14:15
"display", the name for Qt::DisplayRole
See QAbstractItemModel::roleNames() for the default mapping.

Cheers,
_

volcano
29th November 2016, 05:00
Thanks for the suggestion anda_skoa

Is there any way to disable selection in the combobox? I want to use the combobox to show the first item and not allow click on the item at index 1 or index 2

anda_skoa
29th November 2016, 07:59
Not sure. You could try adding a MouseArea to those items and letting it take the events.

Cheers,
_