I have my QTreeView basically working like I want. The only issue is that when I remove a row from a leaf in the QTreeView.
If I have the node expanded when an row is removed it works fine. But when the node is collapsed when I remove the row the arrow next to the leaf is gone until I add a new row or something like that.
EDIT: It seems to not update the leaf's text and add the item when it is collapsed either.
void
NickTreeModel::removeUser(Aki::NickTreeItem *item)
{
int row = -1;
for (int i = 0; i < d->rootItem->childCount(); ++i) {
Aki::NickTreeItem *categoryItem = d->rootItem->child(i);
if ((row = categoryItem->indexOfChild(item)) != -1) {
beginRemoveRows(idx, row, row);
delete categoryItem->takeChild(row);
endRemoveRows();
reset();
}
}
}
void
NickTreeModel::removeUser(Aki::Irc::User *user)
{
int row = -1;
for (int i = 0; i < d->rootItem->childCount(); ++i) {
Aki::NickTreeItem *categoryItem = d->rootItem->child(i);
if ((row = categoryItem->indexOfChild(user)) != -1) {
beginRemoveRows(idx, row, row);
delete categoryItem->takeChild(row);
endRemoveRows();
}
}
}
void
NickTreeModel::removeUser(Aki::NickTreeItem *item)
{
int row = -1;
for (int i = 0; i < d->rootItem->childCount(); ++i) {
QModelIndex idx = index(i, 0);
Aki::NickTreeItem *categoryItem = d->rootItem->child(i);
if ((row = categoryItem->indexOfChild(item)) != -1) {
beginRemoveRows(idx, row, row);
delete categoryItem->takeChild(row);
endRemoveRows();
reset();
}
}
}
void
NickTreeModel::removeUser(Aki::Irc::User *user)
{
int row = -1;
for (int i = 0; i < d->rootItem->childCount(); ++i) {
QModelIndex idx = index(i, 0);
Aki::NickTreeItem *categoryItem = d->rootItem->child(i);
if ((row = categoryItem->indexOfChild(user)) != -1) {
beginRemoveRows(idx, row, row);
delete categoryItem->takeChild(row);
endRemoveRows();
}
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks