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?

Was it helpful?

Solution

You should use ::headerData method of your model. To get number of columns you may use view->model()->columnCount(); method.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top