2

Qtablewidget 和 Qtableview,哪个更适合制作下载任务列表?

我想制作一个像这样的下载任务列表 http://qt-project.org/doc/qt-4.8/images/widgetdelegate.png

  1. 第一个问题是:Qtablewidget还是Qtableview,哪个更适合这个工作?

  2. 第二个问题是:如何在下载任务列表中绘制进度条?PS如果选择 Qtablewidget ,我知道它有一个 QTableWidget.setCellWidget(row, column, widget)

方法,所以我们可以用它在那里设置QprogressBar。如果选择 Qtableview,我们可以像这里一样使用 Delegate

http://qt-project.org/doc/qt-4.8/qabstractitemdelegate.html

(也许 QStyleOptionProgressBarV2 会更适合当前的 Qt )

同样的问题再次出现:哪种方式更合适?

谁能举个小例子?因为 Qt Torrent 示例对于像我这样的新手来说太复杂了。谢谢!

4

1 回答 1

4

Up to me it's very interesting discussion topic. If you look carefully in the documentation you will see that QTableWidget is actually a QTableView with specialised table-oriented functions, default table model, support for widgets in cells out of the box etc. It still has everything which QTableView has if you need some low level customisation. So you really don't have to choose. If you think (and looking on screenshots examples I would agree with that) that QTableWidget can handle most of things you need (like progress bars etc) just take it and go ahead with setCellWidget(...). Since it's QTableView anyway you always have an option to substitute it with your own QTableView implementation with fancy delegates etc. I think in your scenario you you will use very limited amount of QTableWidget specialised functions, so that shouldn't be any problems at all.

Making it short, on your place I would go for QTableWidget.

于 2013-04-19T05:32:56.460 回答