In setModelData for my delegate I perform this code
{
QString name
= index.
model()->data
(index, Qt
::DisplayRole).
toString();
model->setData(index, var,Qt::SizeHintRole);
size = model->data(index, Qt::SizeHintRole).toSize();
}
void ShipComponentDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
{
QString name = index.model()->data(index, Qt::DisplayRole).toString();
QSize size(0,0);
QVariant var = QVariant(size);
model->setData(index, var,Qt::SizeHintRole);
size = model->data(index, Qt::SizeHintRole).toSize();
}
To copy to clipboard, switch view to plain text mode
size taken from model after setting should be the same as above. But it isn't. I thought first time that I made some error with values inserted into size and it is invalid. But no - in every other case with all other values - it doesn't want to change internal data.
To clarify all - in setEditorData() I fill this index with my size - then after changes I want to bring this size to previous value.
Bookmarks