Details
-
Bug
-
Resolution: Fixed
-
P2: Important
-
4.8.x, 5.6.0 Alpha
-
None
-
windows, linux
-
4522b17159a29ffd12c4d93be8a6e8e1a05dccd0
Description
QStandardItemModel::setItem makes the QPersistentModelIndexindex of the row Item invalid.
As per the documentation of QPersistentModelIndex, the item should retain the value of the QPersistentModelIndex until the row item is deleted.
QStandardItemModel *model;
model = new QStandardItemModel;
QStandardItem *item = new QStandardItem();
item->setData(QString("Text 1"), Qt::DisplayRole);
model->appendRow(item);
QStandardItem *item2 = new QStandardItem();
item2->setData(QString("Text 2"), Qt::DisplayRole);
model->appendRow(item2);
QStandardItem *item3 = new QStandardItem();
item3->setData(QString("Text 3"), Qt::DisplayRole);
model->appendRow(item3);
QPersistentModelIndex index = model->index(1,0);
QStandardItem *newItem = new QStandardItem;
newItem->setData("changed text", Qt::DisplayRole);
model->setItem(1, newItem);
//index is now invalid
Attachments
Issue Links
- is duplicated by
-
QTBUG-73000 QComboBox silently invalids the current index, if QStandardItemModel::setItem is called for that index
- Closed
-
QTBUG-80586 QHeaderView sectionResizeMode is reset after setting an item in the model
- Closed