I sent recently an example to the list, entitled "Qt - saving into
dbf" that has a better sample than testbrow. It has edition
capability, and looking into the code, you can see how I get the
current cell with the signal
"currentChanged(QModelIndex,QModelIndex)", as a starting point.
I am getting the current row by the selection change events, called by
this line:
QT_SLOTS_CONNECT(qslots,tb1:SelectionModel(),'currentChanged(QModelIndex,QModelIndex)',{|n|my_select(n,
@nCX1, @nCY1 )})
Whenever the selection changes, (even in the first draw of the grid)
the my_select function is called, and the function stores the current
col and row into @nCX and @nCY. I am doing this, because the selection
in Qt allow one to have multiple cells selected, not only rows and
colums, so you can't simple want to use QModelIndex the way you are
trying below:
> STATIC FUNCTION myShowRow()
> LOCAL i := QModelIndex():from( ????????????? )
> RETURN AllTrim( Str( i:row() ) )
About the sample you asked, using a button to change row is indeed
simple. Change the last two buttons in the sample to this:
( bt2 := QPushButton():new() ):SetText( "Top" )
( bt3 := QPushButton():new() ):SetText( "Bottom" )
And add this below:
QT_SLOTS_CONNECT(qslots,bt2,'clicked()',{||tb1:selectRow( 0 )})
QT_SLOTS_CONNECT(qslots,bt3,'clicked()',{||tb1:selectRow( LastRec()-1 )})
As you want to select the full row, you don't need to use selection
models, the QTableView:selectRow() is enough, as above.
Regards,
Bacco