Harald Scheirich
Harald Scheirich

Reputation: 9764

What deletes the widget created by a custom QItemDelegate

Working with the Qt ItemViews the editing widget of an item can be modified via a QItemDelegate that can create a custom editor via createEditor. Who is responsible for deleting the instance created by the delegate.

I could not find any documentation that explained this, if you just point to the appropriate section that is fine

Upvotes: 2

Views: 1167

Answers (2)

Harald Scheirich
Harald Scheirich

Reputation: 9764

Allright, I did trace this back ...

An editor widget created by a subclass created by QAbstractItemDelegate will get deleted after it has lost focus and the whole signal chain that is documented under delegation has been triggered. It is actually deleted via a deleteLater() call in the QAbstractItemView.

There is the concept of a persistent editor but I did not follow that any further

Upvotes: 7

Arnold Spence
Arnold Spence

Reputation: 22292

QObjects generally take care of themselves as long as their parent is set. When you call createEditor() and specify a parent in the first parameter, the parent will take care of deleting it.

The relevant documentation can be found here, in particular, the third paragraph of the description.

Upvotes: 0

Related Questions