summaryrefslogtreecommitdiffstats
path: root/src/widgets/itemviews
diff options
context:
space:
mode:
authorChen Bin <chenbin@uniontech.com>2021-04-02 13:40:08 +0800
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-05-11 12:35:40 +0000
commitb3d019ac4f5714d33b8d7f143e1bad341cdd8e2b (patch)
tree19639da425b1d5621d49b4971dad3969d28900c2 /src/widgets/itemviews
parent52362abf2c668b4b0769d59d645ed164bbe6d6f5 (diff)
Check scrollbar visibility when computing QListView margins
When the listview setWordWrap is true and ScrollBarPolicy is ScrollBarAsNeeded, if the text needs a newline display and the vbar is not shown, the width of the item was subtracted from the width of the scrollbar. In most cases, the listview needs to reserve the size of the scrollbar. But if the flow is TopToBottom and the vertical scrollbar is not visible, the width of the vertical scrollbar cannot be reserved. Fixes: QTBUG-92366 Change-Id: I73cce691099a253d409019dbb3fe9a16e1830bb1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit aeef92c3c33e4ebcb7e5d8dd955020f4f4600e84) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/widgets/itemviews')
-rw-r--r--src/widgets/itemviews/qlistview.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/widgets/itemviews/qlistview.cpp b/src/widgets/itemviews/qlistview.cpp
index e3dbc097cc..59ba1ec6b6 100644
--- a/src/widgets/itemviews/qlistview.cpp
+++ b/src/widgets/itemviews/qlistview.cpp
@@ -1797,7 +1797,7 @@ void QListViewPrivate::prepareItemsLayout()
// maximumViewportSize() already takes scrollbar into account if policy is
// Qt::ScrollBarAlwaysOn but scrollbar extent must be deduced if policy
// is Qt::ScrollBarAsNeeded
- int verticalMargin = vbarpolicy==Qt::ScrollBarAsNeeded
+ int verticalMargin = (vbarpolicy == Qt::ScrollBarAsNeeded) && (flow == QListView::LeftToRight || vbar->isVisible())
? q->style()->pixelMetric(QStyle::PM_ScrollBarExtent, nullptr, vbar) + frameAroundContents
: 0;
int horizontalMargin = hbarpolicy==Qt::ScrollBarAsNeeded