PDA

View Full Version : How to remove a row from QML table?



neda
9th April 2016, 06:07
Hi,
I am working with QML Tableview.
I want to remove selected row from TableView.
How to remove a row from QML table?

Model of tableview is QStandardItemModel.


MyTableViewColumn {
title: "delete"
width: 15
delegate:Image {
id: name
source: "images/delete.png"
MouseArea{
anchors.fill: parent
anchors.margins: -10
hoverEnabled:true
cursorShape: Qt.PointingHandCursor
onClicked: {
tablemodel.selection.select(tablemodel.currentRow)
myXML.removeRow(tablemodel.currentRow)
tablemodel.currentRow++;
}
}
}
}


void MyXML::removeRow(int index){
// QModelIndex indexRaw=newMyModel->index(index, 0);
newMyModel->removeRow(index);
}

anda_skoa
9th April 2016, 10:59
That looks ok.
Although it is weird that you select the row that you are then deleting.

Cheers,
_