View Full Version : how to set check box on QTableWidget's header

17th April 2017, 13:36
Hi All ,

I'm trying to implement a table widget which has checkable items in it.

And I want to place a check box on the horizontal header to let user "Check
All" and "Uncheck All" by checking or unchecking this check box.

Does anybody know how to do this?

I tried the following:

QTableWidgetItem* item = new QTableWidgetItem("Check");
table->setHorizontalHeaderItem(0, item);

But the header does not have a check box on it.

Thanks in advance

18th April 2017, 22:09
You need to subclass QHeaderView, paint the checkboxes within paintSection(), handle mouse events and replace the original header with your custom one in the view itself.