与实际所要选择的数据不一致。
在选择后这里显示为排序后的索引值,但是在modelChannel中数据 并未重新排序,造成model与显示的数据index不一致,因而在根据显示的index向modex采集数据时,造成数据非想要的数据。
在addressbook的示例里面同样存在这个问题,只能编辑最后一个加入的address,因为每一次row都是0,如果每页只有一条数据。
QModelIndexList listModelIndex = selectionModel->selectedRows();
for (QModelIndexList::Iterator iter = listModelIndex.begin(); iter != listModelIndex.end(); ++iter, ++pChan) {
index = *iter;
row = index.row();
pChan->m_channel =
modelChannel->data(modelChannel->index(row, 0), Qt::DisplayRole).toUInt();
pChan->m_isRecorded =
modelChannel->data(modelChannel->index(row, 1), Qt::DisplayRole).toUInt();
pChan->m_isPrioritied =
modelChannel->data(modelChannel->index(row, 2), Qt::DisplayRole).toUInt();
}
不知道大家如何获取相应数据的?