PDA

View Full Version : Model-Views: How to obtain QTreeWidgetItem from QModelIndex



johnny_sparx
7th April 2006, 19:56
I have a model view with a QTreeWidget and a QAbstractItemModel in the back-end. This works fine.

I have emitted from this widget a QModelIndex which is received by another. Is it possible to retrieve the QTreeWidgetItem that is associated with this datum?

J.

jacek
7th April 2006, 20:04
Either you use QTreeWidget and QTreeWidgetItems or you use QTreeView and a custom model. You can't mix them.

johnny_sparx
8th April 2006, 20:29
I am using a QTreeView and a custom model.

indexFromItem and itemFromIndex are protected members of QTreeWidget. I need to get the model information from an item clicked in a QTree so that I can use it in another widget.

I am having great difficulty with getting the data structure (model) information to another widget.

J.

jacek
8th April 2006, 20:37
If you use QTreeView, then you can't use QTreeWidget methods.

Use QAbstractITemModel::clicked() signal to get the model index and then ask your model for data for that index.