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. Does QSqlTableModel have a limit of records?
Forum Updated to NodeBB v4.3 + New Features

Does QSqlTableModel have a limit of records?

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 586 Views
  • 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by A Former User
    #1

    Does QSqlTableModel have a limit of records that can be retrieved?

    Why am I asking this?
    When I retrieve 9305 database records and apply a QSortFilterProxyModel to the QSqlTableModel my search works. However, when I have 9306 database records the search does not work anymore as expected.

    I can't find any error in the database in the column I am searching. But I'm happy to provide it if someone wants to have a look if they find an error. The database is generated by a python script.

    Do you have any idea what the problem could be if there is no limit?

    JonBJ 1 Reply Last reply
    0
    • ? A Former User

      Does QSqlTableModel have a limit of records that can be retrieved?

      Why am I asking this?
      When I retrieve 9305 database records and apply a QSortFilterProxyModel to the QSqlTableModel my search works. However, when I have 9306 database records the search does not work anymore as expected.

      I can't find any error in the database in the column I am searching. But I'm happy to provide it if someone wants to have a look if they find an error. The database is generated by a python script.

      Do you have any idea what the problem could be if there is no limit?

      JonBJ Online
      JonBJ Online
      JonB
      wrote on last edited by JonB
      #2

      @Gabber
      There should be no such limit. And certainly not at 9,306!

      Re-look at your code. You can show it if you wish, but it probably won't help.

      Don't forget: your QSqlTableModel should have been filled via while (canFetchMore()) fetchMore(); If you have not done this your in-memory records to search may be incomplete.

      ? 1 Reply Last reply
      0
      • JonBJ JonB

        @Gabber
        There should be no such limit. And certainly not at 9,306!

        Re-look at your code. You can show it if you wish, but it probably won't help.

        Don't forget: your QSqlTableModel should have been filled via while (canFetchMore()) fetchMore(); If you have not done this your in-memory records to search may be incomplete.

        ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        @JonB
        Thank you very much. You are a hero!

        @JonB said in Does QSqlTableModel have a limit of records?:

        while (canFetchMore()) fetchMore();

        That solved my problem. Now my code looks like this:

        QSqlTableModel *DatabaseManager::fungusTable() const
        {
            QSqlTableModel *model = new QSqlTableModel;
            model->setTable("Pilze");
            model->setSort(1, Qt::AscendingOrder);
            model->setEditStrategy(QSqlTableModel::OnManualSubmit);
            model->select();
            while (model->canFetchMore()) {
                model->fetchMore();
            }
            return model;
        }
        

        Thanks for your help!

        JonBJ 1 Reply Last reply
        1
        • ? A Former User

          @JonB
          Thank you very much. You are a hero!

          @JonB said in Does QSqlTableModel have a limit of records?:

          while (canFetchMore()) fetchMore();

          That solved my problem. Now my code looks like this:

          QSqlTableModel *DatabaseManager::fungusTable() const
          {
              QSqlTableModel *model = new QSqlTableModel;
              model->setTable("Pilze");
              model->setSort(1, Qt::AscendingOrder);
              model->setEditStrategy(QSqlTableModel::OnManualSubmit);
              model->select();
              while (model->canFetchMore()) {
                  model->fetchMore();
              }
              return model;
          }
          

          Thanks for your help!

          JonBJ Online
          JonBJ Online
          JonB
          wrote on last edited by JonB
          #4

          @Gabber
          Yup. QSortFilterProxyModel is an in-memory-proxy-only, it passes neither the sort nor the filter to the QSqlTableModel (for execution at the SQL side) but rather just sorts/filters what is already in the underlying in-memory model.

          OOI, what version of Qt are you using? Qt6?? Until now/so far as I know QSqlTableModel has always had a value of 256 hard-coded for how many rows it fetches before you have to fetchMore(). Yours looks like that has been increased to 9,306?

          ? 1 Reply Last reply
          0
          • JonBJ JonB

            @Gabber
            Yup. QSortFilterProxyModel is an in-memory-proxy-only, it passes neither the sort nor the filter to the QSqlTableModel (for execution at the SQL side) but rather just sorts/filters what is already in the underlying in-memory model.

            OOI, what version of Qt are you using? Qt6?? Until now/so far as I know QSqlTableModel has always had a value of 256 hard-coded for how many rows it fetches before you have to fetchMore(). Yours looks like that has been increased to 9,306?

            ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #5

            @JonB
            I have Qt-Version 5.15.3.

            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