Results 1 to 3 of 3

Thread: Update problem with QItemDelegate in QTreeView when adding rows

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2006
    Posts
    163
    Thanks
    12
    Thanked 5 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Update problem with QItemDelegate in QTreeView when adding rows

    I have a QItemDelegate set as the delegate for a column in a QTreeView. It's a progress bar showing the progress of threads that are running in the background downloading data. Now, I have a function that parses a file and adds the data to the QTreeView by adding a row to the QTreeView per parsed line in the file. Everything goes ok but for some STRANGE reason I can't isolate, the rows that are currently updating when the data is actually added freeze where they are and never update further. Subsequent rows that are processed by the threads are updated normally however.
    I use the following code to update the progress :

    Qt Code:
    1. void Knewz::updateDownloadProgress( QStandardItem* c, const int &progress )
    2. {
    3. int parent = c->parent()->row();
    4. int child = c->row();
    5. model->item( parent )->child( child, 3 )->setText( QString::number( progress ) );
    6. bool ok;
    7. int rows = model->item( parent )->rowCount();
    8. int prog = 0;
    9. int child_prog = 0;
    10. int children = 0;
    11.  
    12. for( int i = 0; i < rows; ++i ){
    13. child_prog = model->item( parent )->child( i, 3 )->text().toInt( &ok );
    14.  
    15. if( ok ){
    16. prog += child_prog;
    17. ++children;
    18. }
    19.  
    20. }
    21.  
    22. model->item( parent, 3 )->setText( QString::number( prog/rows ) );
    23.  
    24. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by Valheru; 12th June 2007 at 15:55.

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.