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. Why does the vertical scrollbar handle jump up abruptly , while scrolling down to 256'th rows ?
Qt 6.11 is out! See what's new in the release blog

Why does the vertical scrollbar handle jump up abruptly , while scrolling down to 256'th rows ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 3 Posters 2.8k 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.
  • Sudo007S Offline
    Sudo007S Offline
    Sudo007
    wrote on last edited by
    #1

    There is a QTableView in my Qt GUI Application, which displays data , read from sqlite database(the sqlite database has 2000 rows).The view has to show 7 rows at a time. while scrolling down using down arrow button, if the no. of rows crossed to 255, the handle jumps up suddenly. I am using QSqlRelationalTableModel to read data from sqlite database.

    raven-worxR 1 Reply Last reply
    0
    • Sudo007S Sudo007

      There is a QTableView in my Qt GUI Application, which displays data , read from sqlite database(the sqlite database has 2000 rows).The view has to show 7 rows at a time. while scrolling down using down arrow button, if the no. of rows crossed to 255, the handle jumps up suddenly. I am using QSqlRelationalTableModel to read data from sqlite database.

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @Sudo007
      are you using custom widgets?
      If so please show the code...otherwise this is just guessing

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      Sudo007S 1 Reply Last reply
      0
      • Chris KawaC Offline
        Chris KawaC Offline
        Chris Kawa
        Lifetime Qt Champion
        wrote on last edited by Chris Kawa
        #3

        Qt models support an optional "infinite scroll" behavior via canFetchMore and fetchMore.
        This is an optimization so that if your model has say 100000 rows Qt doesn't try to load them all at once.
        The way it works is the model loads only some arbitrary number of rows (256 by default) and returns true from canFetchMore. When you scroll near the bottom edge the view calls fetchMore on the model and another batch is loaded. This happens until you get to the actual last row at which point the model will return false from canFetchMore. Every time another batch is loaded the scrollbar is adjusted to reflect the number of existing items and current position.

        QSqlRelationalTableModel is one of the models implementing "infinite scroll".

        Sudo007S 1 Reply Last reply
        2
        • raven-worxR raven-worx

          @Sudo007
          are you using custom widgets?
          If so please show the code...otherwise this is just guessing

          Sudo007S Offline
          Sudo007S Offline
          Sudo007
          wrote on last edited by
          #4

          @raven-worx
          Hi
          i am not using custom widget and i forgot to mention that my Qt version is Qt 4.8.5.
          Please find the below code-snippet:

          QTableView *m_tableView = new QTableView (this);
          QSqlRelationalTableModel *model = new QSqlRelationalTableModel ;
          model->setTable("myTable");
          model->select();
          m_tableView ->setModel(model);

          1 Reply Last reply
          0
          • Chris KawaC Chris Kawa

            Qt models support an optional "infinite scroll" behavior via canFetchMore and fetchMore.
            This is an optimization so that if your model has say 100000 rows Qt doesn't try to load them all at once.
            The way it works is the model loads only some arbitrary number of rows (256 by default) and returns true from canFetchMore. When you scroll near the bottom edge the view calls fetchMore on the model and another batch is loaded. This happens until you get to the actual last row at which point the model will return false from canFetchMore. Every time another batch is loaded the scrollbar is adjusted to reflect the number of existing items and current position.

            QSqlRelationalTableModel is one of the models implementing "infinite scroll".

            Sudo007S Offline
            Sudo007S Offline
            Sudo007
            wrote on last edited by
            #5

            @Chris-Kawa
            Hi
            i am developing my Qt application using Qt 4.8.5.
            Is its possible to increase the no of loaded rows to 2000 from 256?
            Is there any documentation saying the model loads 256 rows by default.

            I am using the following code-snippet :
            QTableView *m_tableView = new QTableView (this);
            QSqlRelationalTableModel *model = new QSqlRelationalTableModel ;
            model->setTable("myTable");
            model->select();
            m_tableView ->setModel(model);

            raven-worxR 1 Reply Last reply
            0
            • Sudo007S Sudo007

              @Chris-Kawa
              Hi
              i am developing my Qt application using Qt 4.8.5.
              Is its possible to increase the no of loaded rows to 2000 from 256?
              Is there any documentation saying the model loads 256 rows by default.

              I am using the following code-snippet :
              QTableView *m_tableView = new QTableView (this);
              QSqlRelationalTableModel *model = new QSqlRelationalTableModel ;
              model->setTable("myTable");
              model->select();
              m_tableView ->setModel(model);

              raven-worxR Offline
              raven-worxR Offline
              raven-worx
              Moderators
              wrote on last edited by raven-worx
              #6

              @Sudo007
              the value of 255 is hardcoded in the sources.
              Also read the docs of QSqlQueryModel::fetchMore()
              Unfortunately you wont be able to achieve this with SQLite databases unless you recompile Qt and increase this value.

              --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
              If you have a question please use the forum so others can benefit from the solution in the future

              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