[solved] qtreeview edit last inserted item
-
I have a QTreeView.
In this view there are groups with some items in it.
When I create a new group, I'd like to "select" (highlight) this last inserted item.
What is the modelindex of this item?
How can I solve this?(
[This is similar in Windows when you create a new folder]What I exactly want:
create new item (last inserted item...) with a predefined arbitrary name ("group 001")
select it (programatically)
call a delegate's createeditor() method on this item ("simulate" F2 edit key)
edit (rename...)
save (ENTER)
) -
If i understand you correctly
"http://doc.qt.digia.com/stable/itemviews-editabletreemodel.html":http://doc.qt.digia.com/stable/itemviews-editabletreemodel.html
can be helpful for you. Add current lines in insertRow() method:
@QModelIndex child = model->index(index.row()+1, 0, index.parent());
view->selectionModel()->setCurrentIndex(child,QItemSelectionModel::SelectCurrent);
view->edit(child);@ -
YEEEESSSSSS...
This was EXACTLY the solution :)
Thank you! -
I am glad to hear it :)