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. Why can't read properties of list<MapItem> from a Qml map?

Why can't read properties of list<MapItem> from a Qml map?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 306 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.
  • PowerNowP Offline
    PowerNowP Offline
    PowerNow
    wrote on last edited by PowerNow
    #1

    Unfortunately the current methode (create dynamically Qml objects in C++) and then add them to the map via addMapItem is slow. The reason is that I always must iterate through all childrens.

    C++

    QMetaObject::invokeMethod(m_pMapObj, "addPlace", Q_ARG(QVariant, i->id));
    

    Qml

    Map {
       id: iMap
    ...
    
    function addPlace(placeIdx) {
      if (iMap.children) {
          for (var child in iMap.children) {
              var currentPlace = iMap.children[child];
    
             if (currentPlace.idx === placeIdx) {
                  iMap.addMapItem(currentPlace);
                 break;
              }
          }
      }
    }
    }
    

    This works, but too slow. Now I found mapItems

    mapItems : list<MapItem>
    

    I can iterate through the MapQuickItem's but have no access to any property.

    Qml

    for (var chd in iMap.mapItems) {
          var cP = iMap.mapItems[chd];
    
          console.log("name " + cP.sourceItem.objectname);
    }
    

    Output

    qml: name undefined
    

    Does maybe anyone know what I'doing wrong here? Thxs...

    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