When exporting data add a header row
This commit is contained in:
parent
4c175d8c2c
commit
d12fb60af8
1 changed files with 8 additions and 0 deletions
|
|
@ -65,6 +65,14 @@ void exportTable(const QTableView *view, QTextStream &out)
|
||||||
|
|
||||||
auto cols = model->columnCount();
|
auto cols = model->columnCount();
|
||||||
auto rows = model->rowCount();
|
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 (auto row = 0; row < rows; ++row) {
|
||||||
for (int col = 0; col < cols; ++col) {
|
for (int col = 0; col < cols; ++col) {
|
||||||
auto idx = model->index(row, col);
|
auto idx = model->index(row, col);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue