Instead of setting the whole text just set the trimmed one. Set the whole text by using QTableWidgetItem::setData() with Qt::UserRole. Get the text back via QTableWidgetItem::data().


EDIT: And of course:

Salve imperator, vivat princeps optime!