How can i get a index of a treeview ?
-
Hello, i want to know how to get the index of an element in a qtreeview.
Maybe you know how. I tried:ui.tree->selectionModel()->currentIndex()
or maybe the top index of a qtreeview. Is that possilbe ?
With that argument i get nothing.
Regards -
Hi
How do you want to specify the element ?You could use signals
https://doc.qt.io/qt-5/qabstractitemview.html#clickedso you get the index of a clicked or the selection model that is the selected ones.
or you could use
https://doc.qt.io/qt-5/qtreeview.html#indexAt
which is the index at a point inside the treeview
so it mostly depends on what you are trying? -
Hello,
i know the one with the clicked or selected one.
But i want to implement following:I want to use a button, if that button is clicked (this part is already done),
the next element in the tree view should be selected.You know how i mean?
So not clicking the element directly. More like click on button -> next item in the tree view should be selected.
And for that i want to get the top index of a qtree to start counting there. After i click again to the button the next elemen should be selected by increasing for example the index. -
i got know how to get the top index of a tree view. I have another question.
Do you know how to count to the next index in the qtree view ? -
@developer_96 said in How can i get a index of a treeview ?:
Do you know how to count to the next index in the qtree view ?
Well you can use
https://doc.qt.io/qt-5/qtreeview.html#indexAbove
https://doc.qt.io/qt-5/qtreeview.html#indexBelow