Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Forum Updated on Feb 6th

    Unsolved Enter manually in TableView

    QML and Qt Quick
    tableview qml
    1
    1
    532
    Loading More Posts
    • 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.
    • alemio
      alemio last edited by

      Hi, I would to enter and edit the first cell of the tableview pressing the buttonEdit and then edit the next cell pressing buttonEditNext.

      I don't want to use mouse click.

      How can I do?

      import QtQuick 2.6
      import QtQuick.Controls 1.5
      
      ApplicationWindow {
          visible: true
          width: 640
          height: 480
          title: qsTr("Test TableView")
          toolBar: ToolBar {
              height: 50
              Rectangle {
                  id: rectangle
                  anchors.fill: parent
      
                  Button {
                      id: buttonEdit
                      x: 18
                      y: 8
                      width: 100
                      height: 27
                      text: qsTr("Edit")
                      onClicked: {
                          //TODO Go to edit first cell
                      }
                  }
      
                  Button {
                      id: buttonEditNext
                      x: 118
                      y: 8
                      width: 100
                      height: 27
                      text: qsTr("Edit next")
                      onClicked: {
                          //TODO Go to edit next cell
                      }
                  }
              }
          }
          TableView {
              id: tableView
              anchors.fill: parent
               focus: true
      
              TableViewColumn {
                  id: titleColumn
                  title: "Title"
                  role: "title"
                  movable: false
                  resizable: false
                  width: tableView.viewport.width - authorColumn.width
                  delegate: TextInput {
                      anchors.fill: parent
                      id: textInputTitle
                      text: sourceModel.get(styleData.row).title
                  }
              }
      
              TableViewColumn {
                  id: authorColumn
                  title: "Author"
                  role: "author"
                  movable: false
                  resizable: false
                  width: tableView.viewport.width / 3
                  delegate: TextInput {
                      anchors.fill: parent
                      id: textInputAuthor
                      text: sourceModel.get(styleData.row).author
                  }
              }
      
              model: sourceModel
      
              ListModel {
                  id: sourceModel
                  ListElement {
                      title: "Moby-Dick"
                      author: "Herman Melville"
                  }
                  ListElement {
                      title: "The Adventures of Tom Sawyer"
                      author: "Mark Twain"
                  }
              }
          }
      }
      
      1 Reply Last reply Reply Quote 0
      • First post
        Last post