Results 1 to 4 of 4

Thread: QTableView number of rows and scrollbar issue

  1. #1
    Join Date
    Feb 2006
    Posts
    21
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QTableView number of rows and scrollbar issue

    A QTableView is populated by an sqlite database table and has 1000+ rows. When I scroll to the bottom using the scrollbar it goes to about row 512 and then the scrollbar slider jumps up a bit to show that there are more rows. This happens again and again. I'm pretty sure this has to do with allocation but is there a way I can give the Table View the number of rows so that it can anticpate a proper scroll?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTableView number of rows and scrollbar issue

    What model do you use?

  3. #3
    Join Date
    Feb 2006
    Posts
    21
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTableView number of rows and scrollbar issue

    QSqlTableModel

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTableView number of rows and scrollbar issue

    First check if your database driver can report the size of a query executed (using QSqlDriver::hasFeature(QuerySize)). It might be that it doesn't and it could be causing the effect you mention. You can then force reading the whole database like so (run it after "select()"):

    Qt Code:
    1. while (myModel->canFetchMore())
    2. myModel->fetchMore();
    To copy to clipboard, switch view to plain text mode 

  5. The following 2 users say thank you to wysota for this useful post:

    eclarkso (22nd October 2009), jnk5y (6th March 2006)

Similar Threads

  1. Treeview scrollbar not updating when inserting rows
    By Khal Drogo in forum Qt Programming
    Replies: 11
    Last Post: 29th November 2007, 13:13

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.