Retrieve QTreeWidgetItem in delegate
I have a class that inherits QStyledItemDelegate. I override the following methods:
Is it possible to retrieve the QTreeWidgetItem on which the user clicked in the createEditor method of the delegate?
Thanks in advance
Re: Retrieve QTreeWidgetItem in delegate
If you pass a pointer to the tree widget to the delegate so that you can retrieve it in createEditor() then you can use QTreeWidget::itemFromIndex().
Re: Retrieve QTreeWidgetItem in delegate
Sorry for resurrecting this, but it's a very useful post. How does this work, though, since QTreeWidget::itemFromIndex is protected?
Added after 22 minutes:
In the end, I didn't need the item but rather its data. Instead, I called QModelIndex::data() with the appropriate data role and worked with that. That's what QStyledItemDelegate does in the base implementation, by the way. Depending on your use case, that might work for you.