Pris Matic
2011-10-08 23:21:12 UTC
Hi all,
I have a question about what exactly happens when you have a QList<QObject*>
in your C++ code, and then you send it to QML with something like this:
QVariant Abc::GetObjectList()
{ return QVariant::fromValue(m_object_list); }
Where m_object_list is a QList<QObject*> where the QObjects have slots that
can be directly invoked from QML (imagine using the list for something like
a ListView).
Does the QML side of things create a copy of the list, or do I have to
maintain it in C++? Ie if m_object_list was cleared after 'GetObjectList'
was called from QML, then would the list still be valid? If I was using a
ListView, would the ListView need to access that QList if it needed to draw
offscreen delegates as they became visible, etc.
Regards,
-Pris
I have a question about what exactly happens when you have a QList<QObject*>
in your C++ code, and then you send it to QML with something like this:
QVariant Abc::GetObjectList()
{ return QVariant::fromValue(m_object_list); }
Where m_object_list is a QList<QObject*> where the QObjects have slots that
can be directly invoked from QML (imagine using the list for something like
a ListView).
Does the QML side of things create a copy of the list, or do I have to
maintain it in C++? Ie if m_object_list was cleared after 'GetObjectList'
was called from QML, then would the list still be valid? If I was using a
ListView, would the ListView need to access that QList if it needed to draw
offscreen delegates as they became visible, etc.
Regards,
-Pris