title: Checkbox in a header cell in QTableView
body: <p>I want to have a simple column header with a checkbox that selects/ deselects all rows in a QTableView. Clicking the check box in the header causes either to select or deselect all rows. </p>
  
  <p><img src="https://i.stack.imgur.com/7LFP0.png" alt="enter image description here"></p>
  
  <p>When I want to add a check box in a table cell, I have to just return the check state for the Qt::CheckStateRole in the data(..) for the required model indices as below. This is working as expected.</p>
  
  <pre><code>QVariant MyModel::data( const QModelIndex &amp; rIndex, int iRole) const
  {
      ...
  
      if (iRole == Qt::Qt::CheckStateRole)
      {
          return checkstate;
      }
  
  }
  </code></pre>
  
  <p>But when I want to add a checkbox in a header cell, the above method is not working. Hear is my sample code.</p>
  
  <pre><code>QVariant MyModel::headerData( int iSection, Qt::Orientation eOrientation, int iRole) const
  {
      ...
  
      if (iRole == Qt::CheckStateRole)
      {
          return checkstate;
      }
  
  }
  </code></pre>
  
  <p>The QTableView does not call headerData() function in my model with the Qt::CheckStateRole, as it does with data() function. </p>
  
  <p>Why is this behavior? How can I insert a check box in a header cell by only modifying my custom table model?</p>
  
  <p>(I do not want to create a custom QTableView or QHeaderView for this purpose)</p>