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. poll QTableView for selected headers

poll QTableView for selected headers

Scheduled Pinned Locked Moved Solved General and Desktop
qtableviewheader
4 Posts 2 Posters 1.6k 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
    mjsurette
    wrote on 6 Jan 2016, 13:16 last edited by
    #1

    I have a QTableView in which the headers are selectable. I would like to poll its headers to know which headers are selected. I can't find any information on this.

    Is this possible?

    1 Reply Last reply
    0
    • B Offline
      B Offline
      bsomervi
      wrote on 6 Jan 2016, 13:34 last edited by
      #2

      Get the QItemSelectionModel pointer for the relevant QHeaderView and from that use the selected() member to check the selection status of the items.

      1 Reply Last reply
      1
      • B Offline
        B Offline
        bsomervi
        wrote on 6 Jan 2016, 13:37 last edited by
        #3

        Better still, connect the selectionChanged() signal for the header view items then there is no need to poll at all.

        http://doc.qt.io/qt-5/qitemselectionmodel.html#selectionChanged

        M 1 Reply Last reply 6 Jan 2016, 15:48
        0
        • B bsomervi
          6 Jan 2016, 13:37

          Better still, connect the selectionChanged() signal for the header view items then there is no need to poll at all.

          http://doc.qt.io/qt-5/qitemselectionmodel.html#selectionChanged

          M Offline
          M Offline
          mjsurette
          wrote on 6 Jan 2016, 15:48 last edited by
          #4

          @bsomervi
          Better is in the eyes of the beholder. Why keep track of something that the system keeps track of for you? I don't need this information immediately, just when a context menu item is selected.

          Thanks for the answer.

          1 Reply Last reply
          0

          4/4

          6 Jan 2016, 15:48

          • Login

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