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. Extracting QModelIndex from QTreeWidgetItem

Extracting QModelIndex from QTreeWidgetItem

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 2.2k 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.
  • A Offline
    A Offline
    ajaxcrypto
    wrote on last edited by
    #1

    Is there a way to extract the QModelIndex given a QTreeWidgetItem and a column ?

    i.e. QModelIndex index = item->magic(column);

    1 Reply Last reply
    0
    • A Offline
      A Offline
      ajaxcrypto
      wrote on last edited by
      #2

      Solved it finally, trick is to traverse the item hierarchy and construct the index from that.

      1 Reply Last reply
      1
      • JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by JonB
        #3

        From http://doc.qt.io/qt-5/qtreewidget.html#indexFromItem there's a:

        QModelIndex QTreeWidget::indexFromItem(const QTreeWidgetItem *item, int column = 0) const

        It's protected, so do you have your own QTreeWidget-derived class?

        1 Reply Last reply
        3

        • Login

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