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. Store QList<QObject*> as ListElement data in ListModel
Forum Updated to NodeBB v4.3 + New Features

Store QList<QObject*> as ListElement data in ListModel

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

    I am using QList<QObject*> cppObjectList as a context property in my QML module.

    My ListElement form is as follows:

    ListElement {
          _childList: cppObjectList 
    }
    

    Or
    Using ListModel's setProperty(<element_index>, "_childList", cppObjectList ) to set the cppObjectList to _childList

    Then I try printing the _childList (through model._childList) inside my ListView delegate, it just outputs undefined.
    So, anyone knows the reason why or just I cannot do that?

    By the way, I can totally do like this:

    Item {
          id: item
          property var _objectList
    
          function setObjectList() {
                   _objectList = cppObjectList; // cppObjectList is set as QQmlContext property as QVariant.
          }
    }
    

    then use item._objectList as model in my Listview, which is fine!

    So, it seems that cppObjectList can only be set directly to Item's property var and cannot be used as data inside a ListElement, doesn't it?

    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