Friday, 25 May 2018

Add checkbox in QTableView header using icons

There is no API to insert a checkbox into the header of a QTableView. The recommended way of achieving this is to subclass the QHeaderView and draw the checkbox in the paintSection() method which is in my opinion overkill for such a simple feature.

In this post, I show how to achieve a similar effect by simply adding icons in the header. The desired effect is shown below: