Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QSqlRelationalTableModel becomes empty after calling setFilter() by LIMIT 0,5
gbstack last edited by
I need use LIMIT on QSqlRelationalTableModel.
following is the code:
@model->setFilter("1=1 limit 0,100");
model->setRelation(3, QSqlRelation("user_groups", "id", "name"));
after executing above codes, the QSqlRelationalTableModel becomes empty
but if I remove "setFilter()" line, QSqlRelationalTableModel will be correct.
Any suggestion is appreciated.
Hostel last edited by
Which db are you using? Are you tested the query in other db tool?
ChrisW67 last edited by
Most likely failing because setFilter() is expecting a WHERE clause condition and will insert the fragment into the table select accordingly. If the base select has "order by" or "group by" clauses then the "limit 0,5" will be inserted before these where it becomes a syntax error.