Reputation: 7195
Qt 5.5 has a virtual method to define a custom widget for editing mode:
QWidget *createEditor(QWidget *parent,const QStyleOptionViewItem & option ,const QModelIndex & index ) const
But how to use a custom widget to override the "view" mode?
I saw "stars rating" delegate example where paint
method is used but that's not what I need. I need to show a custom widget that contains other standard widgets inside it and use it in a view mode of QTableView
or QListView
. No need to get mess with painting pointers and figures - just show a custom widget (that has .ui file) and contains other standard widgets with their behaviour.
For example:
There is a download manager application that can show downloads either as a table or list view. QListView
with a list of downloads. Each download has URL, Title, TotalSize, DownloadedSize, ProgressBar, Pause button, Remove button, Resume button. All of those can be columns in a table (QTableView
) or composed similar to HTML's DIV in one cell (QListView
widget)
How to achieve it? Is there anything like QWidget *createViewer(...
?
QtWidgets are used no QML.
Upvotes: 5
Views: 1555
Reputation: 9853
For static content you can use QAbstractItemView::setIndexWidget
.
For dynamic content the only option is to implement paint
method in you delegate class.
Upvotes: 1