how to get qstandarditem from qmodelindex using qitemdelegate (qabstractitemmodel)
I have a qstandarditemmodel and a qtableview but when using QItemDelegate to get QLineEdit editor I must declare QAbstractItemModel rather than QStandardItemModel when using Delegate::setModelData, thus I cannot use QstandardItem::itemFromIndex within the setModelData function of the delegate.
How can I get a QStandardItem from a QmodelIndex in this case?
Or how can I use the delegate with QStandardItemModel rather than QAbstractItemModel so that I can access model->itemFromIndex...
Code:
{
QStandardItem *item
= model
->itemFromIndex
(index
);
//itemFromIndex does not exist in this context!
Re: how to get qstandarditem from qmodelindex using qitemdelegate (qabstractitemmodel
I am afraid I don't understand what you've written, but in order to make that code work you need to cast model to QStandardItemModel*.
What do you need the item for?
Cheers,
_
Re: how to get qstandarditem from qmodelindex using qitemdelegate (qabstractitemmodel
Thank you, working.
Code:
{
QStandardItem *item
= sModel
->itemFromIndex
(index.
model()->index
(0,
0));
QList<QStandardItem *> newRows;
item->appendRows( newRows );