Ich habe ein XmlModel geschrieben, und möchte auch eine Zeile daraus löschen. Eigentlich ne simple Sache.
Der Stand ist der:
Code: Alles auswählen
bool XmlModel::removeRow(int row, const QModelIndex &parent)
{
if (row < rowCount(QModelIndex())) {
beginRemoveRows(parent, row, row);
QModelIndex corIndex = index(row, 0, QModelIndex());
DomItem *item = static_cast<DomItem*>(corIndex.internalPointer()); // get pointer
item->parent()->removeChild(row);
rootItem = item->parent();
delete item;
endRemoveRows();
return true;
} // if
return false;
}
Code: Alles auswählen
void DomItem::removeChild(int pos)
{
childItems.remove(pos);
}
Hab den Rest des Codes noch drangehangen, vor allem die .h files sind ja sicher nötig.
Wäre top, wenn jemand Zeit und Motivation hat, mir dabei zu helfen :-7