Yes.
But QList will allocate its memory on the heap anyway.
strange, that part looks ok.
You are just not loading any QML.
Yes, correct.
rowCount() and data() are pure virtual and need to be implemented in order to the class to be instantiable.
roleNames() is necessary for the QML integration.
You already have the enum for the roles.
The only thing there is that you need to base the first enum relative to Qt::UserRole, otherwise the first role's integer value will be 0.
No, these do not have to relate.
The role names are purely for the QML engine.
You don't need to allocate the instance with new, in fact you are currently leaking each object.
There is currently a mismatch between what you tell beginInsertRows() and usng append().
Your beginInsertRows() values say that you are adding the new entry at the beginning, while append() then actually adds it to the end of the list.
Yes.
Your data() method is currently incorrect though.
The role selects which of the fields of one entry you need to return, that part is correct.
But which message to get from the list needs to be derived from the index, i.e. the message that is shown in the respective row.
Alternatively to creatng your own list model you could consider deriving from QSqlQueryModel, adding roleNames() and modifying data() such that is used the role information so that it ask the base class for the right column.
Cheers,
_
Bookmarks