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. Enter manually in TableView
Forum Updated to NodeBB v4.3 + New Features

Enter manually in TableView

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
tableviewqml
1 Posts 1 Posters 602 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.
  • alemioA Offline
    alemioA Offline
    alemio
    wrote on last edited by
    #1

    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
    0

    • Login

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