代码拉取完成,页面将自动刷新
同步操作将从 src-anolis-os/qt5-qtbase 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From 690fe8b7adc60eaf5867c692ebf517e35697c74b Mon Sep 17 00:00:00 2001
From: root <root@localhost.localdomain>
Date: Tue, 5 Jul 2022 10:06:08 +0800
Subject: [PATCH]
0001_fix-QDoubleSpinbox-and-QSpinbox-not-change-value-when-mouse-scroll
---
src/widgets/kernel/qapplication.cpp | 10 ++++++-
src/widgets/widgets/qabstractspinbox.cpp | 34 +++++++++++++-----------
2 files changed, 27 insertions(+), 17 deletions(-)
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index 03e68217..1d5ad478 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -114,6 +114,9 @@
#include <algorithm>
#include <iterator>
+#include <QDoubleSpinBox>
+#include <QSpinBox>
+
//#define ALIEN_DEBUG
static void initResources()
@@ -4092,7 +4095,12 @@ void QApplicationPrivate::giveFocusAccordingToFocusPolicy(QWidget *widget, QEven
if (focusWidget->isEnabled()
&& focusWidget->rect().contains(localPos)
&& QApplicationPrivate::shouldSetFocus(focusWidget, focusPolicy)) {
- focusWidget->setFocus(Qt::MouseFocusReason);
+ if ((qobject_cast<QDoubleSpinBox *>(focusWidget) != nullptr || qobject_cast<QSpinBox *>(focusWidget) != nullptr)
+ && event->type() == QEvent::Wheel) {
+ return;
+ }else{
+ focusWidget->setFocus(Qt::MouseFocusReason);
+ }
break;
}
if (focusWidget->isWindow())
diff --git a/src/widgets/widgets/qabstractspinbox.cpp b/src/widgets/widgets/qabstractspinbox.cpp
index bdceb91f..37479b4d 100644
--- a/src/widgets/widgets/qabstractspinbox.cpp
+++ b/src/widgets/widgets/qabstractspinbox.cpp
@@ -1167,25 +1167,27 @@ void QAbstractSpinBox::keyReleaseEvent(QKeyEvent *event)
void QAbstractSpinBox::wheelEvent(QWheelEvent *event)
{
Q_D(QAbstractSpinBox);
+ if (this->hasFocus()) {
#ifdef Q_OS_MACOS
- // If the event comes from a real mouse wheel, rather than a track pad
- // (Qt::MouseEventSynthesizedBySystem), the shift modifier changes the
- // scroll orientation to horizontal.
- // Convert horizontal events back to vertical whilst shift is held.
- if ((event->modifiers() & Qt::ShiftModifier)
- && event->source() == Qt::MouseEventNotSynthesized) {
- d->wheelDeltaRemainder += event->angleDelta().x();
- } else {
- d->wheelDeltaRemainder += event->angleDelta().y();
- }
+ // If the event comes from a real mouse wheel, rather than a track pad
+ // (Qt::MouseEventSynthesizedBySystem), the shift modifier changes the
+ // scroll orientation to horizontal.
+ // Convert horizontal events back to vertical whilst shift is held.
+ if ((event->modifiers() & Qt::ShiftModifier)
+ && event->source() == Qt::MouseEventNotSynthesized) {
+ d->wheelDeltaRemainder += event->angleDelta().x();
+ } else {
+ d->wheelDeltaRemainder += event->angleDelta().y();
+ }
#else
- d->wheelDeltaRemainder += event->angleDelta().y();
+ d->wheelDeltaRemainder += event->angleDelta().y();
#endif
- const int steps = d->wheelDeltaRemainder / 120;
- d->wheelDeltaRemainder -= steps * 120;
- if (stepEnabled() & (steps > 0 ? StepUpEnabled : StepDownEnabled))
- stepBy(event->modifiers() & d->stepModifier ? steps * 10 : steps);
- event->accept();
+ const int steps = d->wheelDeltaRemainder / 120;
+ d->wheelDeltaRemainder -= steps * 120;
+ if (stepEnabled() & (steps > 0 ? StepUpEnabled : StepDownEnabled))
+ stepBy(event->modifiers() & d->stepModifier ? steps * 10 : steps);
+ event->accept();
+ }
}
#endif
--
2.31.1
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。