Results 1 to 9 of 9

Thread: Refresh TableModel

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2007
    Posts
    52
    Thanks
    6

    Default Refresh TableModel

    I have been trying to get a tableview and table model to work at a reasonable speed lately and it has failed. If I add 100 rows it takes about 14 seconds to refresh the view and forget about trying to scroll...every time I use the scrollbar it lags, skipping lines all over the place.

    I tried to find what is taking so much of the systems resources, by putting qDebug()'s in my function and found that it calls the data() method continuously. It calls this method at least 5 times for each index and each role. Since I have 9 columns and there are seven roles it seems to call the method 31500 times then calls the header. It then starts over again without stopping. None of the data changes and I don't touch the screen while all this happening. It just keeps on calling data.

    I hope what I wrote made some sense. If you could help that would be great.
    My data method is something like this:
    Qt Code:
    1. QVarient class::data(const QModelIndex &index, int role) const
    2. {
    3. if(!index.isValid())
    4. return QVariant;
    5. if(role == Qt:AlignmentRole)
    6. return int(Qt::AlignRight | Qt::AlignVCenter);
    7. else if(role == Qt::DisplayRole)
    8. switch(index.column())
    9. {
    10. case 0: return 1;
    11. case 1: return 1;
    12. case 2: return 1;
    13. case 3: return 1;
    14. case 4: return 1;
    15. case 5: return 1;
    16. case 6: return 1;
    17. case 7: return 1;
    18. case 7: return 1;
    19. }
    20. }
    21. else
    22. return QVariant();
    23. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by jpn; 5th March 2008 at 17:20. Reason: missing [code] tags

Similar Threads

  1. Refresh the Mainwindow at run time
    By sabeesh in forum Qt Programming
    Replies: 3
    Last Post: 15th November 2007, 14:16
  2. QTableView refresh
    By eleanor in forum Qt Programming
    Replies: 9
    Last Post: 6th October 2007, 19:00
  3. refresh form after adding a widget
    By cyrille in forum Newbie
    Replies: 2
    Last Post: 2nd February 2007, 11:40
  4. QTableView refresh problem
    By tebessum in forum Qt Programming
    Replies: 3
    Last Post: 29th December 2006, 12:22
  5. Refresh QDataTable
    By shamik in forum Qt Programming
    Replies: 25
    Last Post: 1st December 2006, 06:04

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
  •  
Qt is a trademark of The Qt Company.