PDA

View Full Version : QML tableView : row is slected ?



Binary01
3rd May 2016, 18:57
Hii everyone,

I have a TableView, and I want to delete a row
First you must select a row and click on Button delete
If the row is not selected ---> msg : No row is selected

My question is : Is there a way to know if the row is selected or no ???

anda_skoa
4th May 2016, 09:33
You can access the view's selection via its "selection" property.
In case you also make the selected row the current row, e.g. through code in the cell's delegate, the you could also check "currentRow"

Cheers,
_

Binary01
4th May 2016, 15:02
Is the view.currentRow always returns = -1, IF no Row is selected ??

For me, the code below works fine


if(view.currentRow == -1){
console.log("No Row is selected !!")
}
else{
console.log("Row is selected OK")
}

anda_skoa
4th May 2016, 16:31
currentRow is not related to selection unless your code makes it so.

Do you set currentRow, e.g. in side the delegate?

Cheers,
_