Lets assume you take the first approach
You get the model
QAbstractItemModel *model = tableView->model();
To copy to clipboard, switch view to plain text mode
To get the number of rows use QAbstractItemModel::rowCount()
const int rowCount = model->rowCount();
const int rowCount = model->rowCount();
To copy to clipboard, switch view to plain text mode
Now you loop over all rows.
For each row you either loop over the columns or address them specifically
QModelIndex index
= model
->index
(currentRow,
0);
// first column;
QModelIndex index = model->index(currentRow, 0); // first column;
To copy to clipboard, switch view to plain text mode
You get the displayed text of a cell from the QModelIndex
QString text
= index.
data(Qt
::DisplayRole).
toString();
QString text = index.data(Qt::DisplayRole).toString();
To copy to clipboard, switch view to plain text mode
Cheers,
_
Bookmarks