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. Urgent help required !!! How to read the tableview index number?
Forum Update on Tuesday, May 27th 2025

Urgent help required !!! How to read the tableview index number?

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 3.3k 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.
  • F Offline
    F Offline
    feedmeqt
    wrote on last edited by
    #1

    Hi,

    I want to store the tableview header index number for each row items. I searched a lot but couldn't find out..

    Waiting for the reply..

    Thanks,

    1 Reply Last reply
    0
    • F Offline
      F Offline
      fluca1978
      wrote on last edited by
      #2

      It is not clear what you need/want. If you want the current row you can do:

      @tableView->currentIndex().row();@

      (check if the index is valid).
      If you need to store each index in each row, so to numbering the rows, you have to work at the model level and add a column with a progressing counter. But it is very unclear to me what you need, since in the subject you state "read" and then in your post "store" the index number. What is your aim?

      1 Reply Last reply
      0
      • A Offline
        A Offline
        andre
        wrote on last edited by
        #3

        Tip: never flag your questions as urgent. They may be for you, but they are not for us, at least not more than the questions of your peers. If you require timely help, I suggest you hire a consultant. This is a public support channel where peers help each other without a guaranteed service level. See "here":http://catb.org/~esr/faqs/smart-questions.html#urgent for more details.

        Second: if you expect any helpful response at all, you will have to be clearer in your questions. I know a thing or two about using the model view framework in Qt, but I have no idea what you mean by this question. Do you mean you are after the QModelIndex for the items in a row of a QTableView? If so, this might help you:

        First step is to realize that the view is not the object you want to query for information, but the model. The view just displays the data, but the model is responsible for actually managing it. The [[doc:QAbstractItemModel]] docs mention a method index. It takes a parent item, a row and a column. You can find out the number of columns from the model as well, using columnCount. As you are working with a table, I will assume the parent item will be 0 (that is: no tree-like structures in your model). You can iterate over the column numbers to request QModelIndex objects for each of the items in a specific row.

        However, note that you can not keep references to these indexes around. They may become invalid. If you want to store the indexes, you should store them in a [[doc:QPersistentModelIndex]] .

        1 Reply Last reply
        0
        • F Offline
          F Offline
          feedmeqt
          wrote on last edited by
          #4

          HI All

          Thanks for the reply. But i actually want to get horizontalHeaderItem for QTableView?

          Waiting fofr reply.

          1 Reply Last reply
          0
          • A Offline
            A Offline
            andre
            wrote on last edited by
            #5

            The header doesn't have indexes or items.

            1 Reply Last reply
            0
            • F Offline
              F Offline
              feedmeqt
              wrote on last edited by
              #6

              Hi,

              Well, your correct. Since I was posting this question behalf of my friend and I think i'm lacking the understanding of his requirement. Now, I've requested my friend to post directly his requirement.

              Sorry for higlighting it!!!

              1 Reply Last reply
              0

              • Login

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