Is there any way to get selected cell position for TableView of QtQuick 2.15?
-
I am using TableView to show some parameters and in the meantime it should be editable so I used TextField, and here comes the problem:
when editing is finished and I cannot specify the cell position of current selection, and setData lost the destination.
Can anyone provide the solution?
NOTE: it is QtQuick 2.15 and it seems nothing is available. -
@walkincloud said in Is there any way to get selected cell position for TableView of QtQuick 2.15?:
when editing is finished and I cannot specify the cell position of current selection, and setData lost the destination.
What do you mean by that?
I have no issue editing a cell. -
@GrecKo said in Is there any way to get selected cell position for TableView of QtQuick 2.15?:
@walkincloud said in Is there any way to get selected cell position for TableView of QtQuick 2.15?:
when editing is finished and I cannot specify the cell position of current selection, and setData lost the destination.
What do you mean by that?
I have no issue editing a cell.I have a set of parameters shown as a row in the table, some entries can be modified in the cell and need to be saved to my c++ program, so the setData should be called but there seems no method to find out which row and column the cell locates?
-
@walkincloud it is not entirely clear what you are trying to do.
I assume that you have implemented the editing of the cell in the table's
delegate
. In the delegate you have access to the current cell'sindex
,row
, andcolumn
. Does this help? -
@Bob64 said in Is there any way to get selected cell position for TableView of QtQuick 2.15?:
@walkincloud it is not entirely clear what you are trying to do.
I assume that you have implemented the editing of the cell in the table's
delegate
. In the delegate you have access to the current cell'sindex
,row
, andcolumn
. Does this help?It is delegate indeed, and it is editable as I expected, but how can I access the cell information through delegate?
-
And here is my delegate
delegate: Rectangle {
id: cellDelegate
implicitWidth: 90
implicitHeight: 35
border.width: 1TextField { id: cellField implicitWidth: 90 implicitHeight: 35 text: display anchors.centerIn: parent onEditingFinished: { tlbModel.setData(tlbModel.index(cellField.row, cellField.column), text) } } }
I have tried cellField.row and cellDelegate.row, but both of them return 0
-
@walkincloud just use
row
andcolumn
. -
Instead of doing
tlbModel.setData(tlbModel.index(row, column), text)
you can dodisplay = text
.display
here is the name of the role that you want to modify. This calls setData under the hood.