QAction: add QT_DEPRECATED_VERSION_6_0 to deprecated methods
And fix all the new warnings. Task-number: QTBUG-104857 Change-Id: I2a5791f495575d71d2344429aca3363f9922e31b Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> (cherry picked from commit 4b9c738185c771127eb8e7c73868f60bd31f7fce) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
8523b68b51
commit
d8e584c7a6
@ -514,14 +514,14 @@ QList<QObject*> QAction::associatedObjects() const
|
|||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn QWidget *QAction::parentWidget() 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.
|
Returns the parent widget.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn QList<QWidget*> QAction::associatedWidgets() const
|
\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.
|
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
|
\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.
|
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.
|
QWidget, QMenu, and QGraphicsWidget can be expected to be fully defined.
|
||||||
*/
|
*/
|
||||||
template<typename T = QWidget*>
|
template<typename T = QWidget*>
|
||||||
|
QT_DEPRECATED_VERSION_X_6_0("Use parent() with qobject_cast() instead")
|
||||||
T parentWidget() const
|
T parentWidget() const
|
||||||
{
|
{
|
||||||
auto result = parent();
|
auto result = parent();
|
||||||
@ -93,6 +94,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename T = QWidget*>
|
template<typename T = QWidget*>
|
||||||
|
QT_DEPRECATED_VERSION_X_6_0("Use associatedObjects() with qobject_cast() instead")
|
||||||
QList<T> associatedWidgets() const
|
QList<T> associatedWidgets() const
|
||||||
{
|
{
|
||||||
QList<T> result;
|
QList<T> result;
|
||||||
@ -102,6 +104,7 @@ public:
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
template<typename T = QGraphicsWidget*>
|
template<typename T = QGraphicsWidget*>
|
||||||
|
QT_DEPRECATED_VERSION_X_6_0("Use associatedObjects() with qobject_cast() instead")
|
||||||
QList<T> associatedGraphicsWidgets() const
|
QList<T> associatedGraphicsWidgets() const
|
||||||
{
|
{
|
||||||
QList<T> result;
|
QList<T> result;
|
||||||
|
@ -215,13 +215,21 @@ void QMenuPrivate::syncPlatformMenu()
|
|||||||
platformMenu->setEnabled(q->isEnabled());
|
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)
|
void QMenuPrivate::copyActionToPlatformItem(const QAction *action, QPlatformMenuItem *item)
|
||||||
{
|
{
|
||||||
item->setText(action->text());
|
item->setText(action->text());
|
||||||
item->setIsSeparator(action->isSeparator());
|
item->setIsSeparator(action->isSeparator());
|
||||||
if (action->isIconVisibleInMenu()) {
|
if (action->isIconVisibleInMenu()) {
|
||||||
item->setIcon(action->icon());
|
item->setIcon(action->icon());
|
||||||
if (QWidget *w = action->parentWidget()) {
|
if (QWidget *w = getParentWidget(action)) {
|
||||||
QStyleOption opt;
|
QStyleOption opt;
|
||||||
opt.initFrom(w);
|
opt.initFrom(w);
|
||||||
item->setIconSize(w->style()->pixelMetric(QStyle::PM_SmallIconSize, &opt, 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)
|
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))
|
if (T *result = qobject_cast<T *>(w))
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user