Use your selection model:
Qt Code:
tableViewPowerDegree->selectionModel()->setCurrentIndex ( const QModelIndex & index, QItemSelectionModel::SelectionFlags command );To copy to clipboard, switch view to plain text mode
Use your selection model:
Qt Code:
tableViewPowerDegree->selectionModel()->setCurrentIndex ( const QModelIndex & index, QItemSelectionModel::SelectionFlags command );To copy to clipboard, switch view to plain text mode
With this command I can set an index, which was what I had shown as code already.
However 'index' does not offer any possibilty to modify the data of row and column.tableViewPowerDegree->setCurrentIndex(...)
Thus I can not set an index that is not selected anyway.
Please prove me that I am wrong.
with the difference that you can specify the selection mode.
The index himself can surely not edit the data (it's not the job of the view), but giving the index to your source model you can modify your data:However 'index' does not offer any possibilty to modify the data of row and column.Qt Code:
To copy to clipboard, switch view to plain text mode
From the docs:Thus I can not set an index that is not selected anyway.
If that's not what you are looking for, please say again what you really want because then I don't have get you right...To set an item as the current item without selecting it, call
selectionModel()->setCurrentIndex(index, QItemSelectionModel::NoUpdate);
I do not want to set data. I only want to select a single cell at a position (row, column) which is not the current selected item. (Sorry, obviously my title was wrong)
I know how to get the index of the current QModelIndex and from that I can get the information about the current row and column. But I can not create a ModelIndex and change its row and column. Therefore a setCurrentIndex is not helping, since its row and column can not be modified.
There exists a selectRow and selectColumn, but I am looking for a selectCell(row, column).
=
Qt Code:
tableView->selectionModel()->select(tabelView->model()->index(row,colum), QItemSelectionModel::Select);To copy to clipboard, switch view to plain text mode
waynew (14th February 2010)
Thank you!
I have now implemented the following to select and edit the next cell in the row.
Qt Code:
int row = index.row() + 1; int column = 1; tableViewPowerDegree->setCurrentIndex(newIndex); tableViewPowerDegree->setFocus(); tableViewPowerDegree->edit(newIndex);To copy to clipboard, switch view to plain text mode
Bookmarks