you may have to format it more like this so that you can access the item later.

Qt Code:
  1. ui.table->setItem( row , 0, new QTableWidgetItem() );
  2. ui.table->item(row , 0 )->setText(QString( "%1" ).arg( num ) );
  3. ui.table->item(row, 0 )->setBackgroundColor( QColor(178,34,34) );
To copy to clipboard, switch view to plain text mode 

Something I found out after hours of invalid pointer access