Lars
Lars

Reputation: 1969

QAbstractItemView::setIndexWidget as editor

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.

Upvotes: 1

Views: 542

Answers (1)

vahancho
vahancho

Reputation: 21250

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.

Upvotes: 1

Related Questions