How to get ListModel from QML to a C++ class?
-
Hello,
Just as my title says is there a way to send a ListModel filled in QML to a C++ class.
I've been using some C++ bindings and Q_PROPERTY to try to achieve this but with no success.
Hopefully there is some example on how to do this.
Thanks in advance :O
-
There is nothing inherently wrong with it.
You should be able to create a property that takes a QObject* and dynamic_cast it to QAbstractItemModel*.That is the trick when doing the other way around. When you create a model from C++ to use in QML, your function/method should return QObject*, it will not work with any of the QAbstract*Model classes that I have tried.
-
[quote author="thiagocorrea" date="1363832522"]There is nothing inherently wrong with it.
You should be able to create a property that takes a QObject* and dynamic_cast it to QAbstractItemModel*.That is the trick when doing the other way around. When you create a model from C++ to use in QML, your function/method should return QObject*, it will not work with any of the QAbstract*Model classes that I have tried.[/quote]
Ok I think I will try your approach. Ill keep posting my results.