Traverse QStandardItem with takeRow
If you appendRow a QList<QStandardItem *>
to a QStandardItem
, you should get the entire row. However takeRow
function removes the element thus you cannot use
//DO NOT USE THIS
QStandardItem *cName;
for (int k = 0; k < cName->rowCount(); ++k) {
QList<QStandardItem*> listOfItems = cName->takeRow(k);
}
Because takeRow
deletes the row from the item. You should use this instead:
//USE THIS
while (cName->hasChildren()) {
QList<QStandardItem*> listOfItems = cName->takeRow(0);
}
Comments