Ok, thank u for your help, but I want to use the setQuery method. And if I use QSqlTableModel this Method isn't available(protected). And the documentation say, that setQuery shouldn't be used.
Do you know a solution?
Ok, thank u for your help, but I want to use the setQuery method. And if I use QSqlTableModel this Method isn't available(protected). And the documentation say, that setQuery shouldn't be used.
Do you know a solution?
Which setQuery do you use? Note that void QSqlQueryModel::setQuery(const QString &query, const QSqlDatabase &db = QSqlDatabase()) is still public, only void QSqlQueryModel::setQuery(const QSqlQuery &query) is protected.
Unfortunately QSqlTableModel has only one setQuery() method and it is this one: QSqlQueryModel::setQuery(const QSqlQuery &query).
What can I do?![]()
Nope! You are wrong!
QSqlTableModel inharits form QSqlQueryModel. One version of setQuery is repated in QSqlTableModel to make it protected for some reason. Second version is still public and you can and should use it.
I tried to make that and know that there are two versions, but the compiler doesn't offer the possibility to use it![]()
Does anybody know why???
This has been asked a lot and it seems there is no easy or direct answer. HERE
It seems implementing your own model is the best bet. I prefer sorting via proxy (QSortFilterProxyModel) but DB access speed can make large models sort slowly.
spawn9997
Bookmarks