diff options
author | Christian Ehrlicher <[email protected]> | 2023-12-17 11:37:29 +0100 |
---|---|---|
committer | Christian Ehrlicher <[email protected]> | 2023-12-21 19:13:32 +0000 |
commit | 9e78256579e8dc704066a98cb4816a1aab0e7e3b (patch) | |
tree | 44cb52bd069979090abef2a1bf9a04bd00644089 | |
parent | f5021835dfb4b0bf974794b598cbdf9f0f95898d (diff) |
Widgets: Use pmf-style connects
Replace some more string-based connects with pmf-style to trigger a
compiler error instead a runtime error if a signal or slot does no
longer exists.
Pick-to: 6.7
Change-Id: Ibc047cc935885a30ea58367fa97e9f962b87ca2c
Reviewed-by: Axel Spoerl <[email protected]>
-rw-r--r-- | src/widgets/kernel/qtooltip.cpp | 8 | ||||
-rw-r--r-- | src/widgets/kernel/qwhatsthis.cpp | 2 | ||||
-rw-r--r-- | src/widgets/kernel/qwidgetaction.cpp | 14 | ||||
-rw-r--r-- | src/widgets/kernel/qwidgetaction.h | 1 | ||||
-rw-r--r-- | src/widgets/kernel/qwidgetaction_p.h | 2 | ||||
-rw-r--r-- | src/widgets/kernel/qwindowcontainer.cpp | 3 |
6 files changed, 15 insertions, 15 deletions
diff --git a/src/widgets/kernel/qtooltip.cpp b/src/widgets/kernel/qtooltip.cpp index 90c9e6dccbb..11c2b5db1b6 100644 --- a/src/widgets/kernel/qtooltip.cpp +++ b/src/widgets/kernel/qtooltip.cpp @@ -179,8 +179,8 @@ void QTipLabel::reuseTip(const QString &text, int msecDisplayTime, const QPoint { #ifndef QT_NO_STYLE_STYLESHEET if (styleSheetParent){ - disconnect(styleSheetParent, SIGNAL(destroyed()), - QTipLabel::instance, SLOT(styleSheetParentDestroyed())); + disconnect(styleSheetParent, &QWidget::destroyed, + this, &QTipLabel::styleSheetParentDestroyed); styleSheetParent = nullptr; } #endif @@ -354,8 +354,8 @@ void QTipLabel::placeTip(const QPoint &pos, QWidget *w) // Set up for cleaning up this later... QTipLabel::instance->styleSheetParent = w; if (w) { - connect(w, SIGNAL(destroyed()), - QTipLabel::instance, SLOT(styleSheetParentDestroyed())); + connect(w, &QWidget::destroyed, + QTipLabel::instance, &QTipLabel::styleSheetParentDestroyed); } // QTBUG-64550: A font inherited by the style sheet might change the size, // particular on Windows, where the tip is not parented on a window. diff --git a/src/widgets/kernel/qwhatsthis.cpp b/src/widgets/kernel/qwhatsthis.cpp index 3dc4808c876..c80f37267f0 100644 --- a/src/widgets/kernel/qwhatsthis.cpp +++ b/src/widgets/kernel/qwhatsthis.cpp @@ -462,7 +462,7 @@ QWhatsThisAction::QWhatsThisAction(QObject *parent) : QAction(tr("What's This?") setIcon(p); #endif setCheckable(true); - connect(this, SIGNAL(triggered()), this, SLOT(actionTriggered())); + connect(this, &QWhatsThisAction::triggered, this, &QWhatsThisAction::actionTriggered); #ifndef QT_NO_SHORTCUT setShortcut(Qt::ShiftModifier | Qt::Key_F1); #endif diff --git a/src/widgets/kernel/qwidgetaction.cpp b/src/widgets/kernel/qwidgetaction.cpp index 4a3fb2be89e..e2845548df8 100644 --- a/src/widgets/kernel/qwidgetaction.cpp +++ b/src/widgets/kernel/qwidgetaction.cpp @@ -82,9 +82,9 @@ QWidgetAction::QWidgetAction(QObject *parent) QWidgetAction::~QWidgetAction() { Q_D(QWidgetAction); - for (int i = 0; i < d->createdWidgets.size(); ++i) - disconnect(d->createdWidgets.at(i), SIGNAL(destroyed(QObject*)), - this, SLOT(_q_widgetDestroyed(QObject*))); + for (QWidget *w : std::as_const(d->createdWidgets)) + QObjectPrivate::disconnect(w, &QWidget::destroyed, + d, &QWidgetActionPrivate::widgetDestroyed); QList<QWidget *> widgetsToDelete = d->createdWidgets; d->createdWidgets.clear(); qDeleteAll(widgetsToDelete); @@ -147,8 +147,8 @@ QWidget *QWidgetAction::requestWidget(QWidget *parent) return d->defaultWidget; } - connect(w, SIGNAL(destroyed(QObject*)), - this, SLOT(_q_widgetDestroyed(QObject*))); + QObjectPrivate::connect(w, &QWidget::destroyed, + d, &QWidgetActionPrivate::widgetDestroyed); d->createdWidgets.append(w); return w; } @@ -175,8 +175,8 @@ void QWidgetAction::releaseWidget(QWidget *widget) if (!d->createdWidgets.contains(widget)) return; - disconnect(widget, SIGNAL(destroyed(QObject*)), - this, SLOT(_q_widgetDestroyed(QObject*))); + QObjectPrivate::disconnect(widget, &QWidget::destroyed, + d, &QWidgetActionPrivate::widgetDestroyed); d->createdWidgets.removeAll(widget); deleteWidget(widget); } diff --git a/src/widgets/kernel/qwidgetaction.h b/src/widgets/kernel/qwidgetaction.h index b8539f275b2..296ff52d1e9 100644 --- a/src/widgets/kernel/qwidgetaction.h +++ b/src/widgets/kernel/qwidgetaction.h @@ -37,7 +37,6 @@ protected: private: Q_DISABLE_COPY(QWidgetAction) - Q_PRIVATE_SLOT(d_func(), void _q_widgetDestroyed(QObject *)) friend class QToolBar; }; diff --git a/src/widgets/kernel/qwidgetaction_p.h b/src/widgets/kernel/qwidgetaction_p.h index 415ac7c9f88..6a1cd8c1863 100644 --- a/src/widgets/kernel/qwidgetaction_p.h +++ b/src/widgets/kernel/qwidgetaction_p.h @@ -34,7 +34,7 @@ public: uint defaultWidgetInUse : 1; uint autoCreated : 1; // created by QToolBar::addWidget and the like - inline void _q_widgetDestroyed(QObject *o) { + inline void widgetDestroyed(QObject *o) { createdWidgets.removeAll(static_cast<QWidget *>(o)); } }; diff --git a/src/widgets/kernel/qwindowcontainer.cpp b/src/widgets/kernel/qwindowcontainer.cpp index 7a7de660127..1247c4c6a67 100644 --- a/src/widgets/kernel/qwindowcontainer.cpp +++ b/src/widgets/kernel/qwindowcontainer.cpp @@ -219,7 +219,8 @@ QWindowContainer::QWindowContainer(QWindow *embeddedWindow, QWidget *parent, Qt: setAcceptDrops(true); - connect(QGuiApplication::instance(), SIGNAL(focusWindowChanged(QWindow*)), this, SLOT(focusWindowChanged(QWindow*))); + connect(qGuiApp, &QGuiApplication::focusWindowChanged, + this, &QWindowContainer::focusWindowChanged); } QWindow *QWindowContainer::containedWindow() const |