[Qt-qml] Behaviour when sending QList<QObject*> as QVariant to QML?

Pris Matic prismatic.project at gmail.com
Sun Oct 9 01:21:12 CEST 2011


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt.nokia.com/pipermail/qt-qml/attachments/20111008/7aaf47f3/attachment.html 


More information about the Qt-qml mailing list