Results 1 to 7 of 7

Thread: QSqlTableModel & treeview

  1. #1
    Join Date
    Nov 2008
    Posts
    12
    Qt products
    Qt4
    Platforms
    Windows

    Default QSqlTableModel & treeview

    Hi

    I am relatively new to Qt so let me start by excusing for not knowing the "obvious".

    I have a mysql table (actually a complicated view) with 4.000.000 entries or approx. 40Gb worth of data.

    I want to make an application where the user can browse through these data, and found QSqlTableModel together with Qtreeview perfect for the job...

    however how do I stop QSqltableModel from trying to read all 4.000.000 entries in one chunck ???? (I do not have enough ram on my notebook).

    What I actually looked for was a widget/model, with a treeview layout, and with buttons for next chunk, previous chunk....but I have not been able to find any example code ?

    Am I on the right track, or do I have to programm everything myself ??

    thanks in advance for a reply...

    jan

  2. #2
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QSqlTableModel & treeview

    I thought QSqlTableModel etc read data on demand?
    (I.e. when you scroll down, further data is requested...)
    Have you checked that all the data is read right at the start?

  3. #3
    Join Date
    Nov 2008
    Posts
    12
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QSqlTableModel & treeview

    Hi.

    that was my understanding too...but after my PC melted down...I ran a mysql trace, to see the statements issued..

    and Qt just sent a normal select...... without the "limit" parameter, meaning mysql collects all data at once...and the treeview explodes.

    but admitted I have also not found anywhere to define how big chuncks treeview should display...there does not seem to be a setCount(), displayNext(), displayPrevious() methods...

    jan

  4. #4
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QSqlTableModel & treeview

    * check QSqlQueryModel::fetchMore()* check if your database driver has that feature

  5. #5
    Join Date
    Nov 2008
    Posts
    12
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QSqlTableModel & treeview

    hi.

    I use the standard mysql driver supplied with Qt4.4.1...

    If I look at the documentation of fetchMore is says:

    Fetches more rows from a database. This only affects databases that don't report back the size of a query (see QSqlDriver::hasFeature()).

    and mysql reports the rowcount back...just to be sure I checked in the source of the driver, and it sets the feature..

    but do you know if I can force that feature off, with the standard mysql driver ??

    jan

  6. #6
    Join Date
    Mar 2008
    Posts
    141
    Thanks
    10
    Thanked 9 Times in 9 Posts

    Default Re: QSqlTableModel & treeview

    Hi,

    there is an app at qt-apps.org (http://www.qt-apps.org/content/show....?content=76696) that does not use a treeview but seems to deal with a similar problem (huge tables). Since I am working on something similar i allways wanted to take a look at it. But I haven't so far ... Maybe this is helpfull for you as well.

  7. #7
    Join Date
    Nov 2008
    Posts
    12
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QSqlTableModel & treeview

    HI.

    thanks a lot, I just had a swift look at the code, and it seems to do the job...at least enough that I can adapt the rest. So now I have some interesting things to do in the weekend.

    thanks again
    jan

Similar Threads

  1. Trouble with "INSERT" by QSqlTableModel
    By AD in forum Qt Programming
    Replies: 12
    Last Post: 10th November 2008, 08:21
  2. Replies: 4
    Last Post: 9th May 2008, 17:02
  3. QSqlTableModel verticak header connect
    By patrik08 in forum Qt Programming
    Replies: 1
    Last Post: 1st July 2007, 13:07
  4. speed of setdata - lots of items in treeview
    By Big Duck in forum Qt Programming
    Replies: 4
    Last Post: 6th July 2006, 12:53
  5. QSqlTableModel
    By raphaelf in forum Qt Programming
    Replies: 4
    Last Post: 4th March 2006, 12:35

Tags for this Thread

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.