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. How to Set the Focus to a moved up Row in QTableView
Qt 6.11 is out! See what's new in the release blog

How to Set the Focus to a moved up Row in QTableView

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 4.0k 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.
  • J Offline
    J Offline
    JoyRider
    wrote on last edited by
    #1

    I have a QTableView with 3 rows and 2 columns. I want to a Move Up / Move Down a Single Row when a Push Button is clicked, I can Move Up / move Down a Single Row when a Push Button is clicked. But the Focus Remains at the same cell. I want to move the Focus of the item which has Moved up / Moved Down.

    EDIT : I will explain it clearly, My TableView Consists of (ex. ) 3 Rows. Now, if i select the 3rd Row and if i click the Move Up button then the 3rd Row item has to move up to the 2nd Row. And if i click the Move Up button again, the 2nd Row Item should Move Up to the 1st Row.

    1 Reply Last reply
    0
    • T Offline
      T Offline
      thEClaw
      wrote on last edited by
      #2

      I guess you should ask the selection model of the tableview to "set the current index":http://qt-project.org/doc/qt-5.1/qtcore/qitemselectionmodel.html#setCurrentIndex to whatever row you wish. As far as I know there is no "focus" obtainable by a cell inside a view, so I assume what you mean is the "current" status - that adds a dotted line around an item.

      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