Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Error with icon in delegate
I have successor of QStyledItemDelegate which consist of button with icon(iconPushButton) and other widgets.
Every item(QStandardIem) in my model has icon too and when i create delegate i do so that the icon in the widget was the same as that of the item. And when user close delegate everything should happen contrary.
1 opeartion duct right, but if i try to set icon of item from delegate widget returns the icon that was in of the item before the call to the delegate.
I try to set icon of item with this code:
@void RDataTreeViewItemDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
const QModelIndex &index) const
RDataTreeViewItemWidget itemWidget = static_cast<RDataTreeViewItemWidget>(editor);
QStandardItemModel *mod = static_cast<QStandardItemModel *>(model);
QStandardItem *item = static_cast<QStandardItem *>(mod->itemFromIndex(index));
mod->setData(index, itemWidget->getText(), Qt::EditRole); //This operation duct right item->setIcon(itemWidget->iconPushButton->icon()); //But this not
Icon of iconPushButton and icon of item is different.
How can i solve this problem?
I know english bad, and i try to present a picture that i want
The code remains the same
Is it a bug in Qt or my fault?