Important: Please read the Qt Code of Conduct -

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

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

    Any suggestion is appreciated.

  • What returns

    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