Qt Code:
  1. QString str = "Some very long text...";
  2. item->setData(Qt::DisplayRole, str.left(4)); // display only the 4 first letters
  3. item->setData(Qt::UserRole, str); // store the whole text, but hidden
  4. // use item normally and add it to the table
  5.  
  6. // at some point you have a pointer to any item
  7. item->data(Qt::DisplayRole); // returns the first 4 letters
  8. item->data(Qt::UserRole); // returns the whole string.
To copy to clipboard, switch view to plain text mode