Store QList<QObject*> as ListElement data in ListModel
-
I am using
QList<QObject*> cppObjectList
as a context property in my QML module.My ListElement form is as follows:
ListElement { _childList: cppObjectList }
Or
UsingListModel's setProperty(<element_index>, "_childList", cppObjectList )
to set thecppObjectList
to_childList
Then I try printing the
_childList
(throughmodel._childList
) inside my ListView delegate, it just outputsundefined
.
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
asmodel
in my Listview, which is fine!So, it seems that
cppObjectList
can only be set directly toItem's property var
and cannot be used as data inside aListElement
, doesn't it?