Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Get List Properties from QML in C++
Forum Update on Monday, May 27th 2025

Get List Properties from QML in C++

Scheduled Pinned Locked Moved QML and Qt Quick
qmlqqmllistpropertc++list of objects
2 Posts 2 Posters 1.4k 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.
  • K Offline
    K Offline
    Kofr
    wrote on last edited by
    #1

    Hi Guys. I m developing converter plugin for QML, and the task is to catch list properties from QML file.
    I have QML components in my plugin.

    qmlRegisterType<Converter>(uri, 1, 0, "Converter");
        qmlRegisterType<Unit>(uri, 1, 0, "Unit");
    

    What I want:
    QML

    Converter {
    Unit {
    name: "g"
    coefficient: 1
    }
    
    Unit {
    name: "Kg"
    coefficient: 1000
    }
    
    }
    

    I want to be able to access list of Unit objects from C++.
    At the moment I have the property in Converter Class:

    Q_PROPERTY(QQmlListProperty<Unit> units READ units NOTIFY unitsChanged)
    

    But I completely fail i tries to get values of QQmlListProperty<Unit> in C++.
    What is the right approach to get these list properties from QML to C++?
    Please help if you know solution. I am struggling with this task for 2 days.

    p3c0P 1 Reply Last reply
    0
    • K Kofr

      Hi Guys. I m developing converter plugin for QML, and the task is to catch list properties from QML file.
      I have QML components in my plugin.

      qmlRegisterType<Converter>(uri, 1, 0, "Converter");
          qmlRegisterType<Unit>(uri, 1, 0, "Unit");
      

      What I want:
      QML

      Converter {
      Unit {
      name: "g"
      coefficient: 1
      }
      
      Unit {
      name: "Kg"
      coefficient: 1000
      }
      
      }
      

      I want to be able to access list of Unit objects from C++.
      At the moment I have the property in Converter Class:

      Q_PROPERTY(QQmlListProperty<Unit> units READ units NOTIFY unitsChanged)
      

      But I completely fail i tries to get values of QQmlListProperty<Unit> in C++.
      What is the right approach to get these list properties from QML to C++?
      Please help if you know solution. I am struggling with this task for 2 days.

      p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      Hi @Kofr
      Check out this example especially this file. There you can use findChild instead to find Converter and then get the data in the same way.

      157

      1 Reply Last reply
      0

      • Login

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