The problem is that you are trying to set the "source" property for the ListElement
of the ListModel
rather than 'text' what it expects. Respectively, if you change the following line:
modelA.append({"source" : "hhhh"})
to:
modelA.append({"text" : "hhhh"})
it will work. Alternatively, you could also add the following line to your ComboBox to get your custom role taking effect:
ComboBox {
model: modelA
textRole: "source"
}
See the ComboBox code for detailed explanation about it:
// No text role set, check whether model has a suitable role
// If 'text' is found, or there's only one role, pick that.
You also have other minor issues in your code, like hard coding the qml path for Windows as showed below. You could change to either "main.qml" simply, or use the resource system.
view.setSource(QUrl("/Users/Qt/program/experiment_apps_and_libs/test/qml/test/main.qml"));
I personally changed it locally simply to:
view.setSource(QUrl("main.qml"));
Also, you seem to have unnecessary qmake options for this experiment set up as follows:
CONFIG += c++11
and
QT += qml quick
For the latter, you do not need to specify qml
explicitly.