Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to set the focus to a specific row/col in a TableView
Forum Updated to NodeBB v4.3 + New Features

How to set the focus to a specific row/col in a TableView

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 2 Posters 1.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.
  • M Offline
    M Offline
    micha-
    wrote on last edited by
    #1

    Hello,

    I have a TableView like shown below. What I want to achieve is that if the user enters a number and presses the Enter key, the cursor is automatically placed in the next row, same column. I could catch the enter key like below, but I guess what I currently can't figure out is how to then set the focus to specific row/col.

    @ TableView {
    id: tableView
    anchors.fill: parent
    model: temperatureModel
    TableViewColumn{role: "tempAvrg"; title: "Average °C."; width: columnWidth}
    TableViewColumn{role: "tempMin"; title: "Min. °C"; width: columnWidth}
    TableViewColumn{role: "tempMax"; title: "Max. °C."; width: columnWidth}
    itemDelegate:
    TextInput {
    id: textInput
    text: styleData.value.toFixed(1)
    Keys.onReturnPressed: {
    //how can I move the focus to the next row, same column?
    console.log("Enter Pressed");
    }
    onEditingFinished: {
    temperatureModel.update(styleData.role, styleData.row, text);
    }
    }
    }
    }@

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Haven't tested it but what about the currentRow/Col properties ?

      Hope it helps

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      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