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 Change-Id: I5710127864909ce9352c7428e6aabbc89981b8f2 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io> (cherry picked from commit fc172e3093397990da73e80b737c17ba63375f2c) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
cf4df23f6d
commit
84c40972fb
@ -170,7 +170,7 @@ public:
|
|||||||
bool autoRepeat() const;
|
bool autoRepeat() const;
|
||||||
|
|
||||||
#if QT_DEPRECATED_SINCE(6,0)
|
#if QT_DEPRECATED_SINCE(6,0)
|
||||||
Q_DECL_DEPRECATED int id() const;
|
QT_DEPRECATED_VERSION_6_0 int id() const;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void setWhatsThis(const QString &text);
|
void setWhatsThis(const QString &text);
|
||||||
@ -181,6 +181,7 @@ public:
|
|||||||
QWidget *parentWidget() const;
|
QWidget *parentWidget() const;
|
||||||
#else
|
#else
|
||||||
template<typename T = QWidget*>
|
template<typename T = QWidget*>
|
||||||
|
QT_DEPRECATED_VERSION_X_6_0("Use parent() and qobject_cast instead")
|
||||||
inline T parentWidget() const
|
inline T parentWidget() const
|
||||||
{ return static_cast<T>(QObject::parent()); }
|
{ return static_cast<T>(QObject::parent()); }
|
||||||
#endif
|
#endif
|
||||||
|
@ -81,7 +81,7 @@ bool qWidgetShortcutContextMatcher(QObject *object, Qt::ShortcutContext context)
|
|||||||
auto w = qobject_cast<QWidget *>(object);
|
auto w = qobject_cast<QWidget *>(object);
|
||||||
if (!w) {
|
if (!w) {
|
||||||
if (auto s = qobject_cast<QShortcut *>(object))
|
if (auto s = qobject_cast<QShortcut *>(object))
|
||||||
w = s->parentWidget();
|
w = qobject_cast<QWidget *>(s->parent());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!w) {
|
if (!w) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user