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 remove a specific row from QML table
Forum Updated to NodeBB v4.3 + New Features

How to remove a specific row from QML table

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

    Hi,

    I am working with QML Tableview, I have created a model to fill data in the rows of QML Table. I am able to fill data succesfull in the table row when i press the "New row data" button, i am also able to remove the rows from the table using "Delete the row" tool button.

    Now i am facing following problems:

    I want to select the row which will be deleted by "delete the row" button, by using up and down buttons.
    So please tell me how i can select a table row entry using up and down tool button and how i can get the index of the selected row, so by pressing delete button i can delete that particular selected row from the table.

    @ToolButton {
    iconSource: "../createrow.png"
    Accessible.name: "New row data"
    onClicked: {
    firstmodel.append({data1: "star", data2:"LASTNAME",data3:"NAME"})

                       }
                    tooltip: "create a new row" }
    
                ToolButton {
    

    Accessible.name: "up"
    iconSource: "../images/up.png"
    onClicked: window1.visible = !window1.visible
    Accessible.name: "Go_upside in the table rows"
    tooltip: "go up" }

                ToolButton { Accessible.name: "down"
                    iconSource: "../Down.png"
                    tooltip: Go_downside in the table rows." }
    
                ToolButton { Accessible.name: "Delete the Row"
                    iconSource: "../delete.png"
                     tooltip: "go down."tooltip: "Delete the row"
                    onClicked: {
                     firstmodel.remove(ListView.currentIndex)
                        console.log(tablemodel.currentIndex)
                       }
                     }@
    
    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      Hi,

      You could use "selection":http://qt-project.org/doc/qt-5/qml-qtquick-controls-tableview.html#selection-prop properties like select and deselect on ToolButton clicked.

      157

      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