According to the Qt documentation

void QAbstractItemView::setIndexWidget ( const QModelIndex & index, QWidget * widget )
Sets the given widget on the item at the given index, passing the ownership of the widget to the viewport.
[...]
This function should only be used to display static content within the visible area corresponding to an item of data. If you want to display custom dynamic content or implement a custom editor widget, subclass QItemDelegate instead.
This function was introduced in Qt 4.1.


I guess setIndexWidget might not be the best way to do that.