QSqlRelationalTableModel becomes empty after calling setFilter() by LIMIT 0,5



  • Hi, everyone

    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"));
    model->select();@
    after executing above codes, the QSqlRelationalTableModel becomes empty

    but if I remove "setFilter()" line, QSqlRelationalTableModel will be correct.

    Any suggestion is appreciated.



  • What returns
    @
    lastError();
    @

    Which db are you using? Are you tested the query in other db tool?



  • 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.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.