You should use ::headerData
method of your model.
To get number of columns you may use view->model()->columnCount();
method.
How can I write the text of QHeaderView's section into a file?
-
28-06-2022 - |
Question
I'm trying to write an exporter, which takes in a QTableView
and writes all its data into a .csv-file, so it can be viewed in MS Excel.
Now I can't seem to find a way to read the text from the horizontal header's sections. There doesn't seem to be a method like QHeaderView::sections
or something like that, so I can't access the QHeaderView's sections. There is a QHeaderView::count
though, which makes me think that they are indeed saved in a container somewhere.
So is there a way to get the text of a section of QHeaderView
?
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow