title: Select rows and columns in QTableWidget, while keeping highlighted
body: <p>I have a QTableWidget that I've set up such that you can't select the cells, but can select rows/columns by their headers. The problem I'm having is when I select a row, it deselects any columns that were selected, and same for column/rows. I want to be able to select rows with the ExtendedSelection behavior and columns with the SingleSelection behavior, but independently of eachother. Here's what I'm doing:</p>
  
  <pre><code>ui-&gt;tableWidget-&gt;setSelectionMode(QAbstractItemView::NoSelection);
  connect(ui-&gt;tableWidget-&gt;horizontalHeader(),SIGNAL(sectionClicked(int)), this,SLOT(horizontalHeaderClicked(int)));
  connect(ui-&gt;tableWidget-&gt;verticalHeader(),SIGNAL(sectionClicked(int)), this,SLOT(verticalHeaderClicked(int)));
  </code></pre>
  
  <p>Then:</p>
  
  <pre><code>void MatrixWidget::horizontalHeaderClicked(int column){
     if(column &lt;= 0) return; //first column is names, doesn't represent a segment
  
     ui-&gt;tableWidget-&gt;setSelectionMode(QAbstractItemView::SingleSelection);
     ui-&gt;tableWidget-&gt;setSelectionBehavior(QAbstractItemView::SelectColumns);
     ui-&gt;tableWidget-&gt;selectColumn(column);
     ui-&gt;tableWidget-&gt;setSelectionMode(QAbstractItemView::NoSelection);
  </code></pre>
  
  <p>}</p>
  
  <pre><code>void MatrixWidget::verticalHeaderClicked(int row){
     ui-&gt;tableWidget-&gt;setSelectionMode(QAbstractItemView::ExtendedSelection);
     ui-&gt;tableWidget-&gt;setSelectionBehavior(QAbstractItemView::SelectRows);
     ui-&gt;tableWidget-&gt;selectRow(row);
     ui-&gt;tableWidget-&gt;setSelectionMode(QAbstractItemView::NoSelection);
  </code></pre>
  
  <p>}</p>