Custom Model with QML_ELEMENT
Unsolved
QML and Qt Quick
-
I'm using cutom C++ model implementation and now declare it through QML_ELEMENT macro:
class Person : public QSortFilterProxyModel { Q_OBJECT QML_ELEMENT Q_PROPERTY(QString name MEMBER m_name) Q_PROPERTY(QString lastname MEMBER m_lastname) Q_PROPERTY(int shoeSize MEMBER m_shoeSize) ... }
Then i instanciate this class in my Qml file:
Person { id: bob name: "Bob Jones" lastname: "Washington" shoeSize: 12 sourceModel: null }
The code is fine, the application runs fine BUT QtCreator don't recognize the property "sourceModel" (and all other QAbstractItemModel properties and signals) and throw me an M16 error "invalid property name"
I just switched to QML_ELEMENT, before i was using qmlRegisterType and it was ok for QtCreator.
Any idea what i'm doing wrong ?Thanks
-
Maybe try explicitly exposing QSortFilterProxyModel?
struct QSortFilterProxyModelForeign { Q_GADGET QML_FOREIGN(QSortFilterProxyModel) QML_NAMED_ELEMENT(QSortFilterProxyModel) // or QML_ANONYMOUS };
-
@GrecKo said in Custom Model with QML_ELEMENT:
Maybe try explicitly exposing QSortFilterProxyModel?
struct QSortFilterProxyModelForeign { Q_GADGET QML_FOREIGN(QSortFilterProxyModel) QML_NAMED_ELEMENT(QSortFilterProxyModel) // or QML_ANONYMOUS };
I tried without success...