QAction: add QT_DEPRECATED_VERSION_6_0 to deprecated methods
And fix all the new warnings. Task-number: QTBUG-104857 Pick-to: 6.4 6.3 6.2 Change-Id: I2a5791f495575d71d2344429aca3363f9922e31b Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>bb10
parent
8fed0a6aa6
commit
4b9c738185
|
|
@ -514,14 +514,14 @@ QList<QObject*> QAction::associatedObjects() const
|
|||
|
||||
/*!
|
||||
\fn QWidget *QAction::parentWidget() const
|
||||
\deprecated Use parent() with qobject_cast() instead.
|
||||
\deprecated [6.0] Use parent() with qobject_cast() instead.
|
||||
|
||||
Returns the parent widget.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QList<QWidget*> QAction::associatedWidgets() const
|
||||
\deprecated Use associatedObjects() with qobject_cast() instead.
|
||||
\deprecated [6.0] Use associatedObjects() with qobject_cast() instead.
|
||||
|
||||
Returns a list of widgets this action has been added to.
|
||||
|
||||
|
|
@ -530,7 +530,7 @@ QList<QObject*> QAction::associatedObjects() const
|
|||
|
||||
/*!
|
||||
\fn QList<QWidget*> QAction::associatedGraphicsWidgets() const
|
||||
\deprecated Use associatedObjects() with qobject_cast() instead.
|
||||
\deprecated [6.0] Use associatedObjects() with qobject_cast() instead.
|
||||
|
||||
Returns a list of graphics widgets this action has been added to.
|
||||
|
||||
|
|
|
|||
|
|
@ -84,6 +84,7 @@ public:
|
|||
QWidget, QMenu, and QGraphicsWidget can be expected to be fully defined.
|
||||
*/
|
||||
template<typename T = QWidget*>
|
||||
QT_DEPRECATED_VERSION_X_6_0("Use parent() with qobject_cast() instead")
|
||||
T parentWidget() const
|
||||
{
|
||||
auto result = parent();
|
||||
|
|
@ -93,6 +94,7 @@ public:
|
|||
}
|
||||
|
||||
template<typename T = QWidget*>
|
||||
QT_DEPRECATED_VERSION_X_6_0("Use associatedObjects() with qobject_cast() instead")
|
||||
QList<T> associatedWidgets() const
|
||||
{
|
||||
QList<T> result;
|
||||
|
|
@ -102,6 +104,7 @@ public:
|
|||
return result;
|
||||
}
|
||||
template<typename T = QGraphicsWidget*>
|
||||
QT_DEPRECATED_VERSION_X_6_0("Use associatedObjects() with qobject_cast() instead")
|
||||
QList<T> associatedGraphicsWidgets() const
|
||||
{
|
||||
QList<T> result;
|
||||
|
|
|
|||
|
|
@ -215,13 +215,21 @@ void QMenuPrivate::syncPlatformMenu()
|
|||
platformMenu->setEnabled(q->isEnabled());
|
||||
}
|
||||
|
||||
static QWidget *getParentWidget(const QAction *action)
|
||||
{
|
||||
auto result = action->parent();
|
||||
while (result && !qobject_cast<QWidget *>(result))
|
||||
result = result->parent();
|
||||
return static_cast<QWidget *>(result);
|
||||
}
|
||||
|
||||
void QMenuPrivate::copyActionToPlatformItem(const QAction *action, QPlatformMenuItem *item)
|
||||
{
|
||||
item->setText(action->text());
|
||||
item->setIsSeparator(action->isSeparator());
|
||||
if (action->isIconVisibleInMenu()) {
|
||||
item->setIcon(action->icon());
|
||||
if (QWidget *w = action->parentWidget()) {
|
||||
if (QWidget *w = getParentWidget(action)) {
|
||||
QStyleOption opt;
|
||||
opt.initFrom(w);
|
||||
item->setIconSize(w->style()->pixelMetric(QStyle::PM_SmallIconSize, &opt, w));
|
||||
|
|
|
|||
|
|
@ -4671,7 +4671,7 @@ void tst_QLineEdit::sideWidgets()
|
|||
|
||||
template <class T> T *findAssociatedWidget(const QAction *a)
|
||||
{
|
||||
foreach (QWidget *w, a->associatedWidgets()) {
|
||||
foreach (QObject *w, a->associatedObjects()) {
|
||||
if (T *result = qobject_cast<T *>(w))
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue