use QAbstractListModel(c++) class in QML ComboBox

  • i tried these :

    ComboBox {
         width: parent.width * 0.9
         height: 40
         model: cplusplusModel.modelList

    and i got:

    Unable to assign cplusplusModel to QString

  • What's the type of cplusplusModel.modelList ?
    Can you show the header ?

  • Not sure what is your model implementation.

    Here is the simple thing which works

    ComboBox {
        model: myModel
        textRole: "name"
    QQmlApplicationEngine engine;

    myModel is inherited from QAbstractListModel. name role is defined in the model.

    Can you share you model implementation ?

  • Thanks @dheerendra

    it worked!.
    i was omitting the textRole.

    My model type is :


Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.