QtQuick2: QAbstractListModel - passing object from C++ to QML [SOLVED]
-
Hello.
I have a project, which is well working in Qt 4.8, but I need to port it to the new version of Qt - 5.1.- I have a class CControl derived from QObject and having a few properties defined by Q_PROPERTY macro. It is registered wit qmlRegisterType.
- I have the CListModel class, which derives from QAbstractListModel and from QList<CControl*> and I'm using it to pass data for the list defined in QML.
- I have defined a role ItemRole (named item).
- When I access it from QML, I just pass (in data() method) my CControl object like this:
@return QVariant::fromValue<CControl*>(ctrl);@
When I try to access the ItemRole from QML like this:
@property CControl control: item@I get an error: Unable to assign ObjectsList_QMLTYPE_102 to CControl.
-
The one who asked for the solution, gave answer. Thats cool :)