From fc172e3093397990da73e80b737c17ba63375f2c Mon Sep 17 00:00:00 2001 From: Ivan Solovev Date: Mon, 11 Jul 2022 14:51:06 +0200 Subject: [PATCH] QShortcut::parentWidget(): Add QT_DEPRECATED_VERSION_X_6_0 And fix the usage that raised a deprecation warning. As a drive-by: fix the deprecation declaration of QShortcut::id() to use QT_DEPRECATED_VERSION_6_0 instead of pure Q_DECL_DEPRECATED. Task-number: QTBUG-104857 Pick-to: 6.4 6.3 6.2 Change-Id: I5710127864909ce9352c7428e6aabbc89981b8f2 Reviewed-by: Volker Hilsheimer Reviewed-by: Marc Mutz --- src/gui/kernel/qshortcut.h | 3 ++- src/widgets/kernel/qshortcut_widgets.cpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qshortcut.h b/src/gui/kernel/qshortcut.h index dbdf6f97f9..d6b48c2817 100644 --- a/src/gui/kernel/qshortcut.h +++ b/src/gui/kernel/qshortcut.h @@ -170,7 +170,7 @@ public: bool autoRepeat() const; #if QT_DEPRECATED_SINCE(6,0) - Q_DECL_DEPRECATED int id() const; + QT_DEPRECATED_VERSION_6_0 int id() const; #endif void setWhatsThis(const QString &text); @@ -181,6 +181,7 @@ public: QWidget *parentWidget() const; #else template + QT_DEPRECATED_VERSION_X_6_0("Use parent() and qobject_cast instead") inline T parentWidget() const { return static_cast(QObject::parent()); } #endif diff --git a/src/widgets/kernel/qshortcut_widgets.cpp b/src/widgets/kernel/qshortcut_widgets.cpp index 968cc898d7..cb184ef07d 100644 --- a/src/widgets/kernel/qshortcut_widgets.cpp +++ b/src/widgets/kernel/qshortcut_widgets.cpp @@ -81,7 +81,7 @@ bool qWidgetShortcutContextMatcher(QObject *object, Qt::ShortcutContext context) auto w = qobject_cast(object); if (!w) { if (auto s = qobject_cast(object)) - w = s->parentWidget(); + w = qobject_cast(s->parent()); } if (!w) {