title: How to maintain vertical scroll position in a QTableWidget
body: <p>This a very simple problem to which I can find no solution:</p>
  
  <p>This is my code:</p>
  
  <pre><code>qint32 pos = ui-&gt;twShow-&gt;verticalScrollBar()-&gt;value();
  ui-&gt;twShow-&gt;blockSignals(true);    
  
  //Code for updating the contents QTableWidget twShow, this is done by erasing all cells and adding them again, in case it matters.
  
  ui-&gt;twShow-&gt;blockSignals(false);
  if (pos &gt; 0){
      ui-&gt;twShow-&gt;verticalScrollBar()-&gt;setValue(pos);
  }
  </code></pre>
  
  <p>What I want to accomplish is simply to maintain the vertical scroll position. However the setValue function ignores the value pos (I've checked by printing the value before and after the instruction and both times its cero).</p>
  
  <p>I have also tried:
     QScrollBar *bar = ui->twShow->verticalScrollBar();
     // Same code as before
     ui->twShow->setVerticalScrollBar(bar); //This line crashes de program</p>
  
  <p>However the last line crashes the program (which I've checked by commenting it, and it works fine).</p>
  
  <p>Any advice would be greatly appreciated...</p>
  
  <p>Thank you very much</p>