S
S
SwitchMan2013-11-28 02:21:08
Qt
SwitchMan, 2013-11-28 02:21:08

QAbstractListModel as model for ComboBox - maybe?

There is a class that inherits from QAbstractListModel. If you set it as a model for ListView for example - it works fine. And for ComboBox it is impossible.

MyСlass {
     id: myModel
}

ComboBox {
     id: comboBox
    model: myModel
}

Gives an error:
/qml/QtQuick/Controls/ComboBox.qml:455: ReferenceError: modelData is not defined
What am I doing wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
kotin, 2016-04-28
@kotin

MyСlass {
id: myModel
}
ComboBox {
id: comboBox
model: myModel
textRole: "name" // or some other role defined in the model
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question