QTableView::sizeHintForRow minor fix of word wrap in a special case
In case we do a resizeSection to 0 (can also happen by a reset) then the auto resize won't work with word wrap. The first resize afterwards it will only resize to a single line. Change-Id: I3abf779ecb0593b6721f5af16f7a39d05004e98f Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
This commit is contained in:
parent
9767824a7d
commit
a920e8d55d
@ -965,7 +965,16 @@ int QTableViewPrivate::heightHintForIndex(const QModelIndex &index, int hint, QS
|
||||
|
||||
if (wrapItemText) {// for wrapping boundaries
|
||||
option.rect.setY(q->rowViewportPosition(index.row()));
|
||||
option.rect.setHeight(q->rowHeight(index.row()));
|
||||
int height = q->rowHeight(index.row());
|
||||
// if the option.height == 0 then q->itemDelegate(index)->sizeHint(option, index) will be wrong.
|
||||
// The option.height == 0 is used to conclude that the text is not wrapped, and hence it will
|
||||
// (exactly like widthHintForIndex) return a QSize with a long width (that we don't use) -
|
||||
// and the height of the text if it was/is on one line.
|
||||
// What we want is a height hint for the current width (and we know that this section is not hidden)
|
||||
// Therefore we catch this special situation with:
|
||||
if (height == 0)
|
||||
height = 1;
|
||||
option.rect.setHeight(height);
|
||||
option.rect.setX(q->columnViewportPosition(index.column()));
|
||||
option.rect.setWidth(q->columnWidth(index.column()));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user