QAbstractItemView::setIndexWidget as editor

524 views Asked by At

Is there any specific reason not to use QAbstractItemView::setIndexWidget for an editor in a QTreeView?

I am having a hell of a time using QStyledItemDelegate's and setItemDelegateForColumn, with data not showing up in editors, checkboxes not replacing the checkbox from QAbstractItemModel.data(index, role).

The docs say not to use it but not why.

1

There are 1 answers

0
vahancho On

Actually docs do not tell to avoid using it at all, but make decision, based on your application behavior. Here is the quote:

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.

I've highlighted the key words that define in which cases you have to use which approach.