Talk:How to Use a QSqlQueryModel in QML: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
(→‎added a request: new section)
 
Line 14: Line 14:
=== Attention: ===
=== Attention: ===
Please note that ''ListView.positionViewAtIndex()'', and possibly other methods of ListView, won't work with QSqlQueryModel. For these methods to work, you have to inherit from QAbstractListModel and override its virtual functions, where you place your database querying.
Please note that ''ListView.positionViewAtIndex()'', and possibly other methods of ListView, won't work with QSqlQueryModel. For these methods to work, you have to inherit from QAbstractListModel and override its virtual functions, where you place your database querying.
== added a request ==
please post the link to the full code please its totally confusing if new people see this

Latest revision as of 17:27, 26 January 2017

This code has helped me so much, but I want to understand it further.

Could anyone help me with question about the codes (under generic approach):

1. Is "m_roleNames" a QSqlQueryModel private variable that is used internally?

  I didn't see it being called in "sqlquerymodel.cpp"

2. At "SqlQueryModel::data" function, why would the columnIdx derived from = role - Qt::UserRole - 1;

  Perhaps someone could share with me how does this function translate from QML role into QSqlQueryModel::data(modelIndex, Qt::DisplayRole);

Thanks,


Attention:

Please note that ListView.positionViewAtIndex(), and possibly other methods of ListView, won't work with QSqlQueryModel. For these methods to work, you have to inherit from QAbstractListModel and override its virtual functions, where you place your database querying.

added a request

please post the link to the full code please its totally confusing if new people see this