title: I'm trying to edit the values in a QTableView when the up or down arrow is pressed, but all I get is empty cells
body: <p>When the up arrow is pressed, I want to increase the current value of the cell by an increment determined by the user. This increment value is in a double spin box called <code>CartIncrement</code>. </p>
  
  <p>Here's my code: </p>
  
  <pre><code>void robotmainwindow::keyPressEvent(QKeyEvent * event)
  {
      int keyPressed = event-&gt;key();
      double newValue = 0;
      QTableWidgetItem newItem;
  
      if (keyPressed == Qt::Key_Up){
          newValue = ui-&gt;CartesianCommandTable-&gt;item(ui-&gt;CartesianCommandTable-&gt;currentRow(),ui-&gt;CartesianCommandTable-&gt;currentColumn())-&gt;text().toDouble() + ui-&gt;CartIncrement-&gt;value();
          newItem.setData(Qt::DisplayRole,newValue);
          ui-&gt;CartesianCommandTable-&gt;setItem(ui-&gt;CartesianCommandTable-&gt;currentRow(), ui-&gt;CartesianCommandTable-&gt;currentColumn(), &amp;newItem);
      }
  
      if (keyPressed == Qt::Key_F1) ui-&gt;robotTab-&gt;setCurrentIndex(0);
      if (keyPressed == Qt::Key_F2) ui-&gt;robotTab-&gt;setCurrentIndex(1);
      if (keyPressed == Qt::Key_F3) ui-&gt;robotTab-&gt;setCurrentIndex(2);
      if (keyPressed == Qt::Key_F4) ui-&gt;robotTab-&gt;setCurrentIndex(3);
      if (keyPressed == Qt::Key_F5) ui-&gt;robotTab-&gt;setCurrentIndex(4);
  }
  </code></pre>
  
  <p>What am I doing wrong? I've created a new <code>QTableWidgetItem</code>, set the data to be the old data plus the increment, and tried the change the data in the current cell using <code>item()</code>. But when I press the up arrow, the default value in the cell, which is 0.0, disappears and the cell is empty.</p>
  
  <p>Also, unrelated, but how can I override the default behavior when the up arrow is pressed? I want to disable table navigation via up and down arrow keys, but keep table navigation via right and left arrow keys. This is because up and down keys should be used to modify table values and right and left should be used to select the cell to be modified. </p>