Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. pass a QVariantList fron c++ to QML
Forum Updated to NodeBB v4.3 + New Features

pass a QVariantList fron c++ to QML

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 1.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • saitejS Offline
    saitejS Offline
    saitej
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      @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
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      saitejS 1 Reply Last reply
      5
      • dheerendraD dheerendra

        @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");

        saitejS Offline
        saitejS Offline
        saitej
        wrote on last edited by
        #3

        @dheerendra

        Thanks!!

        1 Reply Last reply
        1

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved