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