pass a QVariantList fron c++ to QML



  • Hi

    I need to pass a QVariantList from c++ to qml. I have trie the following but it seems to fail.
    mission - c++ class instance
    item - qml QQuickitem

    1. Using connection

    connect(mission,SIGNAL(gridPointsChanged(QVariantList)),item,SLOT(ongridListChanged(QVariantList)));

    I have a function in qml file:
    function ongridListChanged(coordlist){
    console.log(coordlist)
    }

    but it gives an error

    No such slot QMLTYPE_1::ongridListChanged(QVariantList)

    1. using qmlRegisterType:

      qmlRegisterType<Mission>("MissionItem",1,0,"missionitem");
      It gives the error
      module "Mission" is not installed

    Any suggestions to get any of them working?



  • @saitej said:

    qmlRegisterType<Mission>("MissionItem",1,0,"missionitem");

    Please see the example given in the assistant "Data Type Conversion Between QML and C++" for passing QVariantList

    Also Every cml document name need to start with Capital letter. Change like following. It should work.
    qmlRegisterType<Mission>("MissionItem",1,0,"Missionitem");



  • @dheerendra

    Thanks!!


Log in to reply
 

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