PDA

View Full Version : Display a list view with icon, progress bar, text, ...



elfoiros
23rd May 2019, 10:59
Hello,

i'm using Qt5 (win64) and i want to display a list of files with icon, text, progress bar and button. You can see the wanted result in the bellow joined screenshot. I've seen a lot of post but i still don't know the control i need to use : QListView, QListWidget.

Tableview item must be updated on real time (progress bar indicator and status text)

The doc say : Use QListView and subclass QItemDelegate instead.

I can't find any example. How can I do it ?

13140

Thanks

anda_skoa
24th May 2019, 08:37
For the widgets I would say a QTreeView with a QTableModel as the data source or a QTreeView.

Displaying multiple lines of text could potentially be done by having such text as the cell value, but the progressbar will definitely need a custom delegate.

Your subclass will need to override two methods
- QStyledItemDelegate::sizeHint()


- QStyledItemDelegate::paint()


The first needs to return dimensions large enough to fit the cell's content, e.g. to have enough space for the progressbar and the status underneath.
The second then gets called whenever a cell needs to be drawn. For example of a progressbar see ViewDelegate::paintProgressBar() (https://lxr.kde.org/source/extragear/network/ktorrent/ktorrent/view/viewdelegate.cpp) of KTorrent's delegate.

Cheers,
_