title: How to select multiple rows in QTableWidget?
body: <p>I have a table where I've enabled ExtendedSelection:</p>
  
  <pre><code>table.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection)
  </code></pre>
  
  <p>When I close the UI I use QSettings to remember any selected rows. When I re-open my UI I want it to automatically re-select the rows automatically.</p>
  
  <p>I have this, but this ends up only selecting the last selected row:</p>
  
  <pre><code>QSETTINGS = [1, 2, 3]  # Indicates row 1, 2 and 3 should be selected
  
  for row in xrange(table.rowCount()):
      table_item = table.item(row, 1)
      row_data = table_item.data(QtCore.Qt.UserRole)
      row_id = row_data
      if row_id in QSETTINGS:
          table.selectRow(row)  # This ends up only making one row selected
  </code></pre>
  
  <p>What should I use instead of <code>table.selectRow(row)</code> in order to make sure to select more than just one row?</p>
  
  <hr>
  
  <p><strong>Edit</strong></p>
  
  <p>In my original question, I said I was using <code>QtGui.QAbstractItemView.MultiSelection</code>. However, I'm not. I'm using <code>QtGui.QAbstractItemView.ExtendedSelection</code>, which is also why my row selection code obviously doesn't work. By temporarily switching to <code>MultiSelection</code>, selecting the rows and then switch back to <code>ExtendedSelection</code>, the code in my question works great.</p>