In Qt you can obtain this using
QModelIndex index = table->model()->index(row, column);
table->selectionModel()->select(index, QItemSelectionModel::Select);
But I really don't know if current HBQt implements all the classes
needed to do this, as I am currently using my own fork of HBQt.
Perhaps Francesco or Pritpal can help.
Regards;
Bacco
> void QItemSelectionModel::setCurrentIndex ( const QModelIndex & index,
> QItemSelectionModel::SelectionFlags command )
This changes the dotted cursor around the cell. Of course if you are
using single cell selection it somewhat works, but it's problematic
with ranges / multi selection. Can you tell me if
QItemSelectionModel::select ( const QModelIndex & index,
QItemSelectionModel::SelectionFlags command )
is working fine with current HBQt?
Thanks,
Bacco
Please, try this:
oSModel := oTableView:selectionModel()
oSModel:select( oTableView:model():index( row, col), 3 /*
QItemSelectionModel::ClearAndSelect */ )
Or this
oSModel := QItemSelectionModel():from( oTableView:selectionModel() )
oSModel:select( oTableView:model():index( row, col), 3 /*
QItemSelectionModel::ClearAndSelect */ )
And this for multiple selection:
oSModel:select( oTableView:model():index( row, col), 3 /*
QItemSelectionModel::ClearAndSelect */ )
oSModel:select( oTableView:model():index( row, col), 2 /*
QItemSelectionModel::Select */ )
oSModel:select( oTableView:model():index( row, col), 2 /*
QItemSelectionModel::Select */ )
Please tell me if it works, I can't test with my current setup.
Ok, is not the correct way, but it's your project, so you can do
the way you want.
You can select 10 cells with a program while the index is in a 11th cell...
It depends on what CdQ needs to do...
> You can select 10 cells with a program while the index is in a 11th cell...
> It depends on what CdQ needs to do...
Of course it depends. I'm referring only to the question he asked, of
course. By the way, If you have spare time, and can test and report
one of my suggestions, I'll be glad, as I don't have the original HBQt
here. Maybe someone else is using HBQt and such selection seem a
common need.
Many thanks,
Bacco
Thanks for testing. So I conclude you can use this for multiple
selections, if you need in the future:
Function TestBacco1( oTableView )
Local oSModel
oSModel := oTableView:selectionModel()
// This clears previous selection and select a new cell
oSModel:select( oTableView:model():index( 1, 1), 3 /*
QItemSelectionModel::ClearAndSelect */ )
// This selects new cells, but mantain previous selected cells also
(add to selection)
oSModel:select( oTableView:model():index( 1, 2), 2 /*
QItemSelectionModel::Select */ )
oSModel:select( oTableView:model():index( 1, 3), 2 /*
QItemSelectionModel::Select */ )
Return
Also, it would be good if someone adds the QItemSelectionModel:: flags to HBQt
Regards
Bacco