Access QML Model data in c++



  • Is there a way to access a QML based Model (ListModel QDeclarativeListModel, XmlListModel QDeclarativeXmlListModel) data from c++.

    It seems that the headers are private for those models and they don't extend the QAbstractItemModel. Even the interface they implement use private header; QListModelInterface.

    There are two use cases I need this for:

    I want to create a model filter that can be used in QML

    I want to develop my own type of grid view.





  • Thanks shoyeb, but those threads don't discuss what I'm looking for. I'm not trying to access a qml object or its data. I want to use/access/filter the data from a QtQuick based model. Those models include the QDeclarativeListModel and the QDeclarativeXmlListModel.

    One solution I can see right now is to include the private header files for those classes in my project, but I am trying to find a solution without having to include private headers in my project.

    Another solution is to write my own XML and List based models, and force anyone that wants to use my Grid View and my model filter to use the model I developed. I really don't want to do that because I feel that is a waste of time since Qt has already developed those models and they work great.

    I have heard this is a known issue and Qt is not planning on solving this until Qt 5, but I was hoping someone has found a good work around.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.