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 - Current index not correct for contiguous selection with mouse
Forum Updated to NodeBB v4.3 + New Features

QTableView - Current index not correct for contiguous selection with mouse

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 820 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.
  • karl_simmonsK Offline
    karl_simmonsK Offline
    karl_simmons
    wrote on last edited by
    #1

    I am using a QTableView with contiguous selection mode.

    When selecting multiple cells with the mouse, the current index returned by currentIndex() from a slot connected to the selectionChanged signal is always one cell prior to actual current cell (i.e. the cell with the focus rectangle).

    E.g. If the first two cells in the top row are selected (from right to left) with the mouse, currentIndex() will contain (0,0) as the current index, while the actual position (cell with focus rect) is (0,1).

    When using the keyboard to make the selection, the return from currentIndex() is correct.

    Is there a way to get the correct current index using the selectionChanged signal for a selection generated by the mouse?

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      does selectionModel().selectedIndexes() return the correct indexes?
      Are you using a proxy model?

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      1 Reply Last reply
      1
      • karl_simmonsK Offline
        karl_simmonsK Offline
        karl_simmons
        wrote on last edited by
        #3

        Yes, selectionModel().selectedIndexes() returns the correct indexes. I am using a QStandardItemModel.

        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