I implemented standard solution with QAbstractListModel derived class used as a model for qml ListView, it works great. Next step is to separate model from actual data a bit, instead of returning QVariant<QString> ( for example ) from data function I want to return my custom type like this: QVariant<MyType>... then in qml in delegate I want to use it, for example:
// assuming there is data model role named myrole, model data function is returning QVariant<MyType>
Unfortunately such construction does not work, in application output window there is a message that myrole.filename() is undefined, the same happens when MyType has property filename and in qml it is used like "source: myrole.filename". However is there is just " source: myrole" then there is a message "cannot convert MyType to QUrl" which seems to be true
How I should proceed with that? Is such approach possible at all?
Thanks in advance
PS What about pointers, my idea is to return QVariant<MyType*> and actually return a pointer to derived type and then in qml check what type actually is and construct logic basing on that