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. QTableView get the correct index
Forum Updated to NodeBB v4.3 + New Features

QTableView get the correct index

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 225 Views
  • 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.
  • M Offline
    M Offline
    Mikeeeeee
    wrote on last edited by
    #1

    Hi!
    Trying to get the correct index in QTableView
    1.png
    If I do this:

    tableViewTab3Hosts.currentIndex()
    

    it outputs table rows, but the model row starts with 2 instead of 1. How do I get exactly the model string, even if they are not consecutive?
    For the table I use QAbstractTableModel placed in QSortFilterProxyModel

    JonBJ 1 Reply Last reply
    0
    • M Mikeeeeee

      Hi!
      Trying to get the correct index in QTableView
      1.png
      If I do this:

      tableViewTab3Hosts.currentIndex()
      

      it outputs table rows, but the model row starts with 2 instead of 1. How do I get exactly the model string, even if they are not consecutive?
      For the table I use QAbstractTableModel placed in QSortFilterProxyModel

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @Mikeeeeee
      When dealing with indexes and QSortFilterProxyModel you must deal with mapping between the proxy and the underlying model. https://doc.qt.io/qt-5/qsortfilterproxymodel.html#mapFromSource & https://doc.qt.io/qt-5/qsortfilterproxymodel.html#mapToSource. etc. Is this connected to your issue?

      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