0

Im trying to make a download manager that can download multible files and shows them in a qtreeview. Each item in qtreeview should show a filename, progressbar and status text of "Finished" after successfull download.

What is the most simplest and smallest amout code required to add these to qtreeview?

user2753972
  • 21
  • 1
  • 3
  • Take a look at the `torrent` example shipped with Qt. – peppe Nov 20 '13 at 20:01
  • Thank you. I looked at http://qt-project.org/doc/qt-5.0/qtnetwork/torrent-mainwindow-cpp.html and it seems that althought the class they use in that is named TorrentView it really is QTreeWidget not QTreeView. (I realized this when compiler complained about missing setHeaderLabels which QTreeView does not have). So for my case QTreeWidget is the right answer instead of QTreeView ? – user2753972 Nov 20 '13 at 22:39
  • A QTreeView is fine, the important bit in that example is the item delegate that draws a progressbar. – peppe Nov 20 '13 at 22:53
  • Yes. I see it now. This line int progress = qobject_cast(parent())->clientForRow(index.row())->progress() seems to handle the updating but it's unclear to me who and when is this delegate class paint() method called??? By the way, what would have been correct way of setting headers if this torrent example would have used QTreeView instead ? – user2753972 Nov 21 '13 at 00:33
  • Just update your *model*, and emit the `dataChanged` signals. The delegate will then be asked to repaint itself by the view. About the headers: again, provide them in your model's `headerData`. – peppe Nov 21 '13 at 15:31

0 Answers0