I have a QTreeWidget that displays information. It only has top level items, each having 5 fields. Right now, these 5 columns are all text (QString). The last one represents some kind of progress, so I'd like this to be a progress bar (QProgressBar).
The documentation of QTreeWidget says:
So, supposedly I can set any widget for any cell. But I'm unsure of what is meant withvoid QTreeWidget::setItemWidget ( QTreeWidgetItem * item, int column, QWidget * widget )
Sets the given widget to be displayed in the cell specified by the given item and column.
Note that the given widget's autoFillBackground property must be set to true, otherwise the widget's background will be transparent, showing both the model data and the tree widget item.
This function should only be used to display static content in the place of a tree widget item. If you want to display custom dynamic content or implement a custom editor widget, use QTreeView and subclass QItemDelegate instead.
This function was introduced in Qt 4.1.
See also itemWidget() and Delegate Classes.
A progress bar is not static, so it's implied I cannot use it. Or does "static" refer to the fact that it should remain the same widget one it's set?This function should only be used to display static content in the place of a tree widget item.
Or should I use QAbstractItemModel with QTreeView instead? (I have tried this approach briefly, but with no success so far. I'd like to use the QTreeWidget, because it's easier to use, rather that putting many hours in the abstract model.)
Bookmarks