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
|
#ifndef QT_NO_STYLE_STYLESHEET
|
||||||
if (styleSheetParent){
|
if (styleSheetParent){
|
||||||
disconnect(styleSheetParent, SIGNAL(destroyed()),
|
disconnect(styleSheetParent, &QWidget::destroyed,
|
||||||
QTipLabel::instance, SLOT(styleSheetParentDestroyed()));
|
this, &QTipLabel::styleSheetParentDestroyed);
|
||||||
styleSheetParent = nullptr;
|
styleSheetParent = nullptr;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -354,8 +354,8 @@ void QTipLabel::placeTip(const QPoint &pos, QWidget *w)
|
|||||||
// Set up for cleaning up this later...
|
// Set up for cleaning up this later...
|
||||||
QTipLabel::instance->styleSheetParent = w;
|
QTipLabel::instance->styleSheetParent = w;
|
||||||
if (w) {
|
if (w) {
|
||||||
connect(w, SIGNAL(destroyed()),
|
connect(w, &QWidget::destroyed,
|
||||||
QTipLabel::instance, SLOT(styleSheetParentDestroyed()));
|
QTipLabel::instance, &QTipLabel::styleSheetParentDestroyed);
|
||||||
}
|
}
|
||||||
// QTBUG-64550: A font inherited by the style sheet might change the size,
|
// 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.
|
// 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);
|
setIcon(p);
|
||||||
#endif
|
#endif
|
||||||
setCheckable(true);
|
setCheckable(true);
|
||||||
connect(this, SIGNAL(triggered()), this, SLOT(actionTriggered()));
|
connect(this, &QWhatsThisAction::triggered, this, &QWhatsThisAction::actionTriggered);
|
||||||
#ifndef QT_NO_SHORTCUT
|
#ifndef QT_NO_SHORTCUT
|
||||||
setShortcut(Qt::ShiftModifier | Qt::Key_F1);
|
setShortcut(Qt::ShiftModifier | Qt::Key_F1);
|
||||||
#endif
|
#endif
|
||||||
|
@ -82,9 +82,9 @@ QWidgetAction::QWidgetAction(QObject *parent)
|
|||||||
QWidgetAction::~QWidgetAction()
|
QWidgetAction::~QWidgetAction()
|
||||||
{
|
{
|
||||||
Q_D(QWidgetAction);
|
Q_D(QWidgetAction);
|
||||||
for (int i = 0; i < d->createdWidgets.size(); ++i)
|
for (QWidget *w : std::as_const(d->createdWidgets))
|
||||||
disconnect(d->createdWidgets.at(i), SIGNAL(destroyed(QObject*)),
|
QObjectPrivate::disconnect(w, &QWidget::destroyed,
|
||||||
this, SLOT(_q_widgetDestroyed(QObject*)));
|
d, &QWidgetActionPrivate::widgetDestroyed);
|
||||||
QList<QWidget *> widgetsToDelete = d->createdWidgets;
|
QList<QWidget *> widgetsToDelete = d->createdWidgets;
|
||||||
d->createdWidgets.clear();
|
d->createdWidgets.clear();
|
||||||
qDeleteAll(widgetsToDelete);
|
qDeleteAll(widgetsToDelete);
|
||||||
@ -147,8 +147,8 @@ QWidget *QWidgetAction::requestWidget(QWidget *parent)
|
|||||||
return d->defaultWidget;
|
return d->defaultWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(w, SIGNAL(destroyed(QObject*)),
|
QObjectPrivate::connect(w, &QWidget::destroyed,
|
||||||
this, SLOT(_q_widgetDestroyed(QObject*)));
|
d, &QWidgetActionPrivate::widgetDestroyed);
|
||||||
d->createdWidgets.append(w);
|
d->createdWidgets.append(w);
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
@ -175,8 +175,8 @@ void QWidgetAction::releaseWidget(QWidget *widget)
|
|||||||
if (!d->createdWidgets.contains(widget))
|
if (!d->createdWidgets.contains(widget))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
disconnect(widget, SIGNAL(destroyed(QObject*)),
|
QObjectPrivate::disconnect(widget, &QWidget::destroyed,
|
||||||
this, SLOT(_q_widgetDestroyed(QObject*)));
|
d, &QWidgetActionPrivate::widgetDestroyed);
|
||||||
d->createdWidgets.removeAll(widget);
|
d->createdWidgets.removeAll(widget);
|
||||||
deleteWidget(widget);
|
deleteWidget(widget);
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,6 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(QWidgetAction)
|
Q_DISABLE_COPY(QWidgetAction)
|
||||||
Q_PRIVATE_SLOT(d_func(), void _q_widgetDestroyed(QObject *))
|
|
||||||
friend class QToolBar;
|
friend class QToolBar;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ public:
|
|||||||
uint defaultWidgetInUse : 1;
|
uint defaultWidgetInUse : 1;
|
||||||
uint autoCreated : 1; // created by QToolBar::addWidget and the like
|
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));
|
createdWidgets.removeAll(static_cast<QWidget *>(o));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -219,7 +219,8 @@ QWindowContainer::QWindowContainer(QWindow *embeddedWindow, QWidget *parent, Qt:
|
|||||||
|
|
||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
|
|
||||||
connect(QGuiApplication::instance(), SIGNAL(focusWindowChanged(QWindow*)), this, SLOT(focusWindowChanged(QWindow*)));
|
connect(qGuiApp, &QGuiApplication::focusWindowChanged,
|
||||||
|
this, &QWindowContainer::focusWindowChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
QWindow *QWindowContainer::containedWindow() const
|
QWindow *QWindowContainer::containedWindow() const
|
||||||
|
Loading…
x
Reference in New Issue
Block a user