When exporting data add a header row

This commit is contained in:
eelke 2021-04-10 09:48:48 +02:00
parent 4c175d8c2c
commit d12fb60af8

View file

@ -65,6 +65,14 @@ void exportTable(const QTableView *view, QTextStream &out)
auto cols = model->columnCount();
auto rows = model->rowCount();
// header
for (int col = 0; col < cols; ++col) {
auto display_text = model->headerData(col, Qt::Horizontal, Qt::DisplayRole).toString();
csv.writeField(display_text);
}
csv.nextRow();
for (auto row = 0; row < rows; ++row) {
for (int col = 0; col < cols; ++col) {
auto idx = model->index(row, col);