title: How can I set the initial index for Shift + click selection in Qt QTableView?
body: <p>My issue is that after Ctrl + click deselect of an item. It became the initial index of the following Shift + click select.</p>
  <p>What I would like to happen is set the initial index of the Shift selection to index 0.</p>
  <p>For example:</p>
  <pre><code>#include &lt;QApplication&gt;
  #include &lt;QtWidgets&gt;
  
  
  int main(int argc, char *argv[])
  {
      QApplication a(argc, argv);
      QStringListModel model({&quot;1&quot;, &quot;2&quot;, &quot;3&quot;, &quot;4&quot;, &quot;5&quot;, &quot;6&quot;, &quot;7&quot;, &quot;8&quot;, &quot;9&quot;});
      QTableView view;
      view.horizontalHeader()-&gt;setVisible(false);
      view.setSelectionBehavior(QAbstractItemView::SelectRows);
      view.setSelectionMode(QAbstractItemView::ExtendedSelection);
      view.setModel(&amp;model);
      view.show();
  
      return a.exec();
  }
  </code></pre>
  <ol>
  <li><p>Select row header 2<br/>
  <a href="https://i.stack.imgur.com/gRpOy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gRpOy.png" alt="enter image description here" /></a></p>
  </li>
  <li><p>Deselect row header 2 using Ctrl + click <br/>
  <a href="https://i.stack.imgur.com/C8rqs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/C8rqs.png" alt="enter image description here" /></a></p>
  </li>
  <li><p>Shift + click row header 5<br/>
  <a href="https://i.stack.imgur.com/thlk8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/thlk8.png" alt="enter image description here" /></a></p>
  </li>
  </ol>
  <p>Expected result:
  Row 1, 2, 3, 4, and 5 are selected.</p>
  <p>Actual result:
  Rows 2, 3, 4, and 5 are selected.</p>
  <p>Is there any way to produce the expected result?</p>