QTableWidget - Word Wrap
-
from "http://doc.qt.nokia.com/4.7/qtableview.html#wordWrap-prop":http://doc.qt.nokia.com/4.7/qtableview.html#wordWrap-prop
If this property is true then the item text is wrapped where necessary at word-breaks; otherwise it is not wrapped at all. This property is true by default.
Note that even of wrapping is enabled, the cell will not be expanded to fit all text. Ellipsis will be inserted according to the current textElideMode. -
It seems that the resizeRowToContents(row) does work (somewhat).
However when I create the row like this :
@
TableWidgetItem *descriptionItem = new QTableWidgetItem("String");
descriptionItem->setFlags(Qt::ItemIsEnabled);
setItem (row, column,descriptionItem);
resizeRowToContents(index);
@It has no effet on the row.
I have to manually call resizeRowToContents(index) with a timer to make it work.
Any thoughts?
Edit: Use tag @ for code
-
try it to adjust one of the columns to adapt to the size of QTableWdiget :
@
int col =2; // chose the column 2 for adjust;
QTableWdiget *tw = new QTableWdiget(this);
tw->horizontalHeader()->setResizeMode(col,QHeaderView::Stretch);
@ -
Although this is an old thread I think I came up with a very simple solution:
@
connect(
tableWidget->horizontalHeader(),
SIGNAL(sectionResized(int, int, int)),
tableWidget,
SLOT(resizeRowsToContents()));
@
This will adjust the word wrapping automatically every time a column resizes.