Results 1 to 6 of 6

Thread: Limitation when adding more than 256 items to a model

  1. #1
    Join Date
    May 2006
    Posts
    70
    Thanks
    12
    Thanked 4 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Limitation when adding more than 256 items to a model

    I have a simple contact database application that stores names and phone numbers etc.

    I've subclassed my own model which has lots of logic and uses a QSqlTableModel for actual storage (for reasons which i won't go into here).

    My setup for developing is Linux + Qt4 + GCC + MySql.
    My testing setup is Windows 2k + Qt4 + MinGW + MS-Sql Server (via odbc)

    On linux I have no problems adding new items to the model.
    On the windows setup I can only add 256 item and then it stops working.

    Is this a modelindex/persistantmodelindex problem? a limitation of window qt4? a limitiation of mingw? something else entirely?

  2. #2
    Join Date
    Jan 2006
    Location
    Ukraine,Lviv
    Posts
    454
    Thanks
    9
    Thanked 27 Times in 27 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: Limitation when adding more than 256 items to a model

    Quote Originally Posted by darkadept
    a limitation of window qt4? a limitiation of mingw?
    Yes it can be cause of suspicion
    a life without programming is like an empty bottle

  3. #3
    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: Limitation when adding more than 256 items to a model

    What does "stop working" mean? Can you add those entries manually using the sql calls? Maybe the database is set up incorrectly?

  4. #4
    Join Date
    May 2006
    Posts
    70
    Thanks
    12
    Thanked 4 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Limitation when adding more than 256 items to a model

    Sorry for the incoherent post. I was debugging this thing far too late into the night.

    I can still insert new items into the model and that successfully saves to the database, so i'm not suspecting the DB anymore.

    I am not using a Qt view to display my model but had to create my own "view" class to do it. I had tried subclassing the QAbstractItemView class but could never get that to work properly (i'll save that for a different post). So in my "view" class i have to keep track of which ModelIndex i'm currently on, etc. (My view only displays one item in the model at a time). The user can move forward and back through the items in the model.

    What's odd is that it works fine under Linux/Mysql but doesn't work under Windows/MSSQL. My first thought I had when I heard it wasn't letting the user move past #256 was an issue with typing. I thought that maybe the "int" with linux/gcc has a different bit-size then the "int" on windows/mingw.

    I've got more debugging to do, i know, but i was wondering if anyone else has run into this kind of problem when porting from linux to windows.

  5. #5
    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: Limitation when adding more than 256 items to a model

    The models themselves don't introduce limitations on both Linux and Windows. The problem has to lie in your code somewhere between the model and the user interaction. Can you move through the model manually? For example try this:
    Qt Code:
    1. qDebug(qPrintable(model->data(300,0).toString()));
    To copy to clipboard, switch view to plain text mode 

  6. The following user says thank you to wysota for this useful post:

    darkadept (25th May 2006)

  7. #6
    Join Date
    May 2006
    Posts
    70
    Thanks
    12
    Thanked 4 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Talking Re: Limitation when adding more than 256 items to a model

    And you're right!
    After much qDebug()ing I got it. And, of course, it's something really stupid.

    The problem was with my reimplemented rowCount function. I was just returning my QSqlTableModel's rowcount. The problem there is that the QMYSQL driver supports the QSqlDriver::QuerySize feature while QODBC driver doesn't. That means in windows I was stuck with the default 256-record cache.

    The workaround i have now is to run a "SELECT COUNT(id) FROM table" and return that value in my model's rowCount method. This is far from efficient and run's sluggishly.

    I guess I could maintain a counter and increase/decrease as I add and remove records. Or is there a better way to do this?

    (THANKS so much for the help!)

Similar Threads

  1. Table model / view editing issue
    By Caius Aérobus in forum Qt Programming
    Replies: 9
    Last Post: 7th April 2006, 11:03
  2. [Qt4]: Adding centered items in QListWidget
    By Jojo in forum Qt Programming
    Replies: 4
    Last Post: 16th March 2006, 20:04
  3. Adding tooltips to canvas items
    By jnana in forum Qt Programming
    Replies: 2
    Last Post: 2nd March 2006, 10:53
  4. [QT3] QComboBox: Disable adding items on Enter-keypress
    By BrainB0ne in forum Qt Programming
    Replies: 7
    Last Post: 14th January 2006, 19:43

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.