No, this is a short answer. A QModelIndex
is the index into the model, not the data stored in the model at that index. You should call data( const QModelIndex& index, int role = Qt::DisplayRole) const
on your model with index
being your QModelIndex. If you're just dealing with text, a DislayRole should suffice.
Yes, how you get the selected item is correct, but depending on your selection mode, it may return more than one QModelIndex
(in a QModelIndexList
).
source share