diff options
author | Thorbjørn Martsum <tmartsum@gmail.com> | 2013-05-31 06:40:44 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-07-04 18:55:10 +0200 |
commit | a920e8d55db46aeec4e3a5800c46a19c8ba4b14c (patch) | |
tree | e853460ba5aedce6dfab1302be53203669abe3b6 /src | |
parent | 9767824a7dc9379a0959968b2ae9b047fce14856 (diff) |
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>
Diffstat (limited to 'src')
-rw-r--r-- | src/widgets/itemviews/qtableview.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/widgets/itemviews/qtableview.cpp b/src/widgets/itemviews/qtableview.cpp index 990e07bfcb..d282397c1b 100644 --- a/src/widgets/itemviews/qtableview.cpp +++ b/src/widgets/itemviews/qtableview.cpp @@ -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())); } |