Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How can i get a index of a treeview ?
Forum Updated to NodeBB v4.3 + New Features

How can i get a index of a treeview ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 2 Posters 376 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    developer_96
    wrote on last edited by developer_96
    #1

    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

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      How do you want to specify the element ?

      You could use signals
      https://doc.qt.io/qt-5/qabstractitemview.html#clicked

      so 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?

      1 Reply Last reply
      2
      • D Offline
        D Offline
        developer_96
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • D Offline
          D Offline
          developer_96
          wrote on last edited by
          #4

          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 ?

          mrjjM 1 Reply Last reply
          0
          • D developer_96

            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 ?

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @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

            1 Reply Last reply
            1

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved