I have QTableView with 100+ rows in it. But at a time only 6 rows are visible. To see next set of rows, I have to use scrool bar.
I want to print visible rows in QTableView. But could not do that. I could just able to print single selected row.
QItemSelectionModel *select = _table->selectionModel();
QModelIndexList selectedRow = select->selectedRows();
QModelIndex index = selectedRow.at(0);
int columnCount = 2; // there are 2 columns in a row
QString copySelectedRowText_;
for(int i = 0 ; i < columnCount; i++)
{
copySelectedRowText_ += index.sibling(index.row(), i).data().toString()+ " ";
}
qDebug() << copySelectedRowText_;
How to print visible rows in QTableView?
You can get the current line number through the
value()of theverticalScrollbar, and you can also get the number of displayable lines throughpagestep().This is my code ,you can try it: