代码拉取完成,页面将自动刷新
同步操作将从 src-anolis-os/qt5-qtbase 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From c0f754214f5a9a9cc792ca245c6f873cc79ffb33 Mon Sep 17 00:00:00 2001
From: root <root@localhost.localdomain>
Date: Tue, 5 Jul 2022 10:55:11 +0800
Subject: [PATCH]
QTBUG-94248-Check-scrollbar-ScrollBarOverlap-when-computing-QListView-margins
---
src/widgets/itemviews/qlistview.cpp | 1 +
.../itemviews/qlistview/tst_qlistview.cpp | 31 +++++++++++++++++++
2 files changed, 32 insertions(+)
diff --git a/src/widgets/itemviews/qlistview.cpp b/src/widgets/itemviews/qlistview.cpp
index 57bfdcde..99224f9c 100644
--- a/src/widgets/itemviews/qlistview.cpp
+++ b/src/widgets/itemviews/qlistview.cpp
@@ -1823,6 +1823,7 @@ void QListViewPrivate::prepareItemsLayout()
// Qt::ScrollBarAlwaysOn but scrollbar extent must be deduced if policy
// is Qt::ScrollBarAsNeeded
int verticalMargin = (vbarpolicy == Qt::ScrollBarAsNeeded) && (flow == QListView::LeftToRight || vbar->isVisible())
+ && !q->style()->pixelMetric(QStyle::PM_ScrollView_ScrollBarOverlap, nullptr, vbar)
? q->style()->pixelMetric(QStyle::PM_ScrollBarExtent, nullptr, vbar) + frameAroundContents
: 0;
int horizontalMargin = hbarpolicy==Qt::ScrollBarAsNeeded
diff --git a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
index d80cc6bd..46589dd7 100644
--- a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
+++ b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
@@ -37,6 +37,7 @@
#include <QTest>
#include <QTimer>
#include <QtMath>
+#include <QProxyStyle>
#include <QtTest/private/qtesthelpers_p.h>
#include <QtWidgets/private/qlistview_p.h>
@@ -168,6 +169,7 @@ private slots:
void taskQTBUG_51086_skippingIndexesInSelectedIndexes();
void taskQTBUG_47694_indexOutOfBoundBatchLayout();
void itemAlignment();
+ void spacingWithWordWrap_data();
void spacingWithWordWrap();
void internalDragDropMove_data();
void internalDragDropMove();
@@ -2567,8 +2569,37 @@ void tst_QListView::taskQTBUG_47694_indexOutOfBoundBatchLayout()
/*!
Verify fix for QTBUG-92366
*/
+void tst_QListView::spacingWithWordWrap_data()
+{
+ QTest::addColumn<bool>("scrollBarOverlap");
+
+ QTest::addRow("Without overlap") << false;
+ QTest::addRow("With overlap") << true;
+}
+
void tst_QListView::spacingWithWordWrap()
{
+ QFETCH(bool, scrollBarOverlap);
+
+ class MyStyle : public QProxyStyle
+ {
+ bool scrollBarOverlap;
+ public:
+ MyStyle(bool scrollBarOverlap) : scrollBarOverlap(scrollBarOverlap) {}
+
+ int pixelMetric(PixelMetric metric, const QStyleOption *option = nullptr,
+ const QWidget *widget = nullptr) const override{
+ switch (metric) {
+ case QStyle::PM_ScrollView_ScrollBarOverlap: return scrollBarOverlap;
+ default:
+ break;
+ }
+ return QProxyStyle::pixelMetric(metric, option, widget);
+ }
+ };
+
+ QApplication::setStyle(new MyStyle(scrollBarOverlap));
+
const int listViewResizeCount = 200;
QWidget window;
window.resize(300, 200);
--
2.31.1
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。