Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QSqlRelationalTableModel becomes empty after calling setFilter() by LIMIT 0,5
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 1.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    gbstack
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • H Offline
      H Offline
      Hostel
      wrote on last edited by
      #2

      What returns
      @
      lastError();
      @

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

      1 Reply Last reply
      0
      • C Offline
        C Offline
        ChrisW67
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved