qsurvae
1st July 2015, 11:54
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...
void Delegate::setModelData(QWidget * editor, QAbstractItemModel * model, const QModelIndex & index) const
{
QStandardItem *item = model->itemFromIndex(index); //itemFromIndex does not exist in this context!
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...
void Delegate::setModelData(QWidget * editor, QAbstractItemModel * model, const QModelIndex & index) const
{
QStandardItem *item = model->itemFromIndex(index); //itemFromIndex does not exist in this context!