Have you something like this in your code before this loop :
Qt Code:
  1. table.setColumnCount(2);
To copy to clipboard, switch view to plain text mode 
And
Qt Code:
  1. table.repaint();
To copy to clipboard, switch view to plain text mode 
is not required.