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. Change-Id: Ibc047cc935885a30ea58367fa97e9f962b87ca2c Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> (cherry picked from commit 9e78256579e8dc704066a98cb4816a1aab0e7e3b) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
f8a8b99f98
commit
fcd3cb7230
@ -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.
|
||||
|
@ -464,7 +464,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
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -37,7 +37,6 @@ protected:
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(QWidgetAction)
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_widgetDestroyed(QObject *))
|
||||
friend class QToolBar;
|
||||
};
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
};
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user