QT Remove Horizontal header of table
c++, qt
Solution
The `horizontalHeader` in a `QTableView` is a widget like any other. If you want to hide it, just call its `hide()` member (which is a slot too).
view->horizontalHeader()->hide();
This hides the whole header bar. It doesn't destroy or otherwise change the contained header items.
When you want the header to be displayed again, simply `show()` it. The header items will remain as they were before the `hide()` (unless you've changed them in between).
view->horizontalHeader()->show();
(Works for the vertical header too, obviously.)
Problem
I have a function `setHorizontalHeader`,which adds a header to the table by adding header items one by one using `setHorizontalHeaderItem`.If I want to delete a header which function should I use? Looks that `takeHorizontalHeaderItem`() suits, but it removes the item without deleting it. After caling takeHorizontalHeaderItem for all items I get the header with numbers inside it. I need to entirely delete the header (data + cells) – How do I implement it correctly?