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. QML property list empty when accessed from C++
Forum Updated to NodeBB v4.3 + New Features

QML property list empty when accessed from C++

Scheduled Pinned Locked Moved QML and Qt Quick
1 Posts 1 Posters 663 Views 1 Watching
  • 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.
  • S Offline
    S Offline
    SmokeOnTheWater
    wrote on last edited by
    #1

    Good afternoon,

    How can a qml property list be accessed from C++ side?

    I think an example should make things clear:
    @
    // MyItem.qml
    Rectangle
    {
    // some properties
    }

    // MyComponent.qml,
    CppComponent // available through qmlRegisterType<CMyComponent>("myComponents", 1, 0, "CppComponent");
    {
    width: 100
    height: 62

    property list<MyItem> myItems;
    

    }
    @

    @
    // Usage.qml
    Rectangle
    {
    width: 100
    height: 62

    MyComponent
    {
        myItems: // <--- the property list gets filled here
        [
            MyItem
            {
                x: 100
                y: interpolator.rotationCenter.y
                width: 150
                height: 200
            },
    
            MyItem
            {
                x: 100
                y: interpolator.rotationCenter.y
                width: 150
                height: 200
            }
        ]
    }
    

    }
    @

    The big question is: how can the property list be accessed from C++
    side?

    My stupid approach was:
    @
    QQmlListProperty<QQuickItem> mis = this->property("maskItems").value<QQmlListProperty<QQuickItem> >();
    @

    because
    @
    this->property("maskItems").typeName();
    @

    returns "QQmlListProperty<MyItem_QMLTYPE_0>"

    But the list is empty...

    I also tried a QList<QQuickItem *>, QVariantList and some other stupid things
    I cannot remember anymore but it's the same all the time:
    no items are contained in the list when it is accessed from C++ side

    What's wrong here?

    Thank you in advance,
    Martin

    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