From d12fb60af862348c9380aedfa2129b1d0f7e4d37 Mon Sep 17 00:00:00 2001 From: eelke Date: Sat, 10 Apr 2021 09:48:48 +0200 Subject: [PATCH] When exporting data add a header row --- pglablib/util.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pglablib/util.cpp b/pglablib/util.cpp index 788e2c0..bdd6bef 100644 --- a/pglablib/util.cpp +++ b/pglablib/util.cpp @@ -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);