QMenu/QToolBar: remove addAction() functions

They're now in QWidget itself. Remove them from the API, but not the
ABI.

The QToolBar case is straight-forward. QMenu is a bit more complicated:

Since QT_CONFIG(shortcut) builds changed the signature of an existing
function instead of adding/removing an overload, we have to deal with
two cases: In a QT_CONFIG(shortcut) build, these overloads that take a
trailing QKeySequence parameter have been deprecated and therefore
cannot be removed. In a !QT_CONFIG(shortcut) build, the same functions
are 1:1 copies of QWidget functions and can be removed (from the API).

[ChangeLog][QtWidgets][QMenu/QToolBar] The addAction() functions have
been moved down into QWidget.

Change-Id: I49997b3440c137a1d4e3858d1d27d34a191e1eed
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
This commit is contained in:
Marc Mutz 2021-07-08 16:27:52 +02:00
parent 08e4d2db08
commit 09d1196281
12 changed files with 220 additions and 363 deletions

View File

@ -78,8 +78,8 @@ QKeySequence(Qt::CTRL + Qt::Key_X, Qt::CTRL + Qt::Key_C); // deprecated
void Wrapper::wrapper() {
//! [2]
QMenu *file = new QMenu(this);
file->addAction(tr("&Open..."), this, SLOT(open()),
QKeySequence(tr("Ctrl+O", "File|Open")));
file->addAction(tr("&Open..."), QKeySequence(tr("Ctrl+O", "File|Open")),
this, SLOT(open()));
//! [2]
} // Wrapper::wrapper

View File

@ -59,8 +59,8 @@ MainWindow::MainWindow()
{
QMenu *fileMenu = new QMenu(tr("&File"));
fileMenu->addAction(tr("E&xit"), this, SLOT(close()),
QKeySequence(tr("Ctrl+Q", "File|Exit")));
fileMenu->addAction(tr("E&xit"), QKeySequence(tr("Ctrl+Q", "File|Exit")),
this, SLOT(close()));
QMenu *actionsMenu = new QMenu(tr("&Actions"));
actionsMenu->addAction(tr("&Highlight List Items"),
@ -69,8 +69,8 @@ MainWindow::MainWindow()
QMenu *insertMenu = new QMenu(tr("&Insert"));
insertMenu->addAction(tr("&List"), this, SLOT(insertList()),
QKeySequence(tr("Ctrl+L", "Insert|List")));
insertMenu->addAction(tr("&List"), QKeySequence(tr("Ctrl+L", "Insert|List")),
this, SLOT(insertList()));
menuBar()->addMenu(fileMenu);
menuBar()->addMenu(insertMenu);

View File

@ -57,13 +57,13 @@ MainWindow::MainWindow()
{
QMenu *fileMenu = new QMenu(tr("&File"));
fileMenu->addAction(tr("E&xit"), this, SLOT(close()),
QKeySequence(tr("Ctrl+Q", "File|Exit")));
fileMenu->addAction(tr("E&xit"), QKeySequence(tr("Ctrl+Q", "File|Exit")),
this, SLOT(close()));
QMenu *insertMenu = new QMenu(tr("&Insert"));
insertMenu->addAction(tr("&List"), this, SLOT(insertList()),
QKeySequence(tr("Ctrl+L", "Insert|List")));
insertMenu->addAction(tr("&List"), QKeySequence(tr("Ctrl+L", "Insert|List")),
this, SLOT(insertList()));
menuBar()->addMenu(fileMenu);
menuBar()->addMenu(insertMenu);

View File

@ -60,8 +60,8 @@ MainWindow::MainWindow()
{
QMenu *fileMenu = new QMenu(tr("&File"));
fileMenu->addAction(tr("&Open..."), this, SLOT(openFile()),
QKeySequence(tr("Ctrl+O", "File|Open")));
fileMenu->addAction(tr("&Open..."), QKeySequence(tr("Ctrl+O", "File|Open"))
this, SLOT(openFile()));
printAction = fileMenu->addAction(tr("&Print..."), this, SLOT(printFile()));
printAction->setEnabled(false);
@ -69,8 +69,8 @@ MainWindow::MainWindow()
pdfPrintAction = fileMenu->addAction(tr("Print as P&DF..."), this, SLOT(printPdf()));
pdfPrintAction->setEnabled(false);
fileMenu->addAction(tr("E&xit"), this, SLOT(close()),
QKeySequence(tr("Ctrl+Q", "File|Exit")));
fileMenu->addAction(tr("E&xit"), QKeySequence(tr("Ctrl+Q", "File|Exit")),
this, SLOT(close()));
menuBar()->addMenu(fileMenu);

View File

@ -55,8 +55,8 @@ MainWindow::MainWindow()
{
QMenu *fileMenu = new QMenu(tr("&File"));
fileMenu->addAction(tr("&Open..."), this, SLOT(openFile()),
QKeySequence(tr("Ctrl+O", "File|Open")));
fileMenu->addAction(tr("&Open..."), QKeySequence(tr("Ctrl+O", "File|Open")),
this, SLOT(openFile()));
QAction *quitAction = fileMenu->addAction(tr("E&xit"), this, SLOT(close()));
quitAction->setShortcut(tr("Ctrl+Q"));

View File

@ -47,6 +47,7 @@ qt_internal_add_module(Widgets
widgets/qabstractscrollarea.cpp widgets/qabstractscrollarea.h widgets/qabstractscrollarea_p.h
widgets/qfocusframe.cpp widgets/qfocusframe.h
widgets/qframe.cpp widgets/qframe.h widgets/qframe_p.h
widgets/qtwidgets_widgets_removed_functions_in_6_3.cpp
widgets/qwidgetanimator.cpp widgets/qwidgetanimator_p.h
DEFINES
QT_NO_USING_NAMESPACE
@ -237,6 +238,15 @@ set(qstyle_resource_files
"styles/images/viewlist-32.png"
)
set(widgets_no_pch_sources
widgets/qtwidgets_widgets_removed_functions_in_6_3.cpp
)
foreach(src ${widgets_no_pch_sources})
qt_update_ignore_pch_source(Widgets ${src})
endforeach()
qt_internal_add_resource(Widgets "qstyle"
PREFIX
"/qt-project.org/styles/commonstyle"

View File

@ -1757,162 +1757,75 @@ QMenu::~QMenu()
hideTearOffMenu();
}
#if QT_DEPRECATED_SINCE(6, 4)
/*!
This convenience function creates a new action with \a text.
The function adds the newly created action to the menu's
list of actions, and returns it.
\fn QAction *QMenu::addAction(const QString &text, const QObject *receiver, const char* member, const QKeySequence &shortcut)
\obsolete
QMenu takes ownership of the returned QAction.
\sa QWidget::addAction()
Use \c{QWidget::addAction(text, shortcut, receiver, member)} instead.
*/
QAction *QMenu::addAction(const QString &text)
{
QAction *ret = new QAction(text, this);
addAction(ret);
return ret;
}
/*!
\overload
This convenience function creates a new action with an \a icon
and some \a text. The function adds the newly created action to
the menu's list of actions, and returns it.
QMenu takes ownership of the returned QAction.
\sa QWidget::addAction()
*/
QAction *QMenu::addAction(const QIcon &icon, const QString &text)
{
QAction *ret = new QAction(icon, text, this);
addAction(ret);
return ret;
}
/*!
\overload
This convenience function creates a new action with the text \a
text and an optional shortcut \a shortcut. The action's
\l{QAction::triggered()}{triggered()} signal is connected to the
\a receiver's \a member slot. The function adds the newly created
action to the menu's list of actions and returns it.
QMenu takes ownership of the returned QAction.
\sa QWidget::addAction()
*/
QAction *QMenu::addAction(const QString &text, const QObject *receiver, const char* member
#if QT_CONFIG(shortcut)
, const QKeySequence &shortcut
#endif
)
QAction *QMenu::addAction(const QString &text, const QObject *receiver, const char* member, const QKeySequence &shortcut)
{
QAction *action = new QAction(text, this);
#if QT_CONFIG(shortcut)
action->setShortcut(shortcut);
#endif
QObject::connect(action, SIGNAL(triggered(bool)), receiver, member);
addAction(action);
return action;
return QWidget::addAction(text, shortcut, receiver, member);
}
#endif
/*!\fn template<typename Functor> QAction *QMenu::addAction(const QString &text, Functor functor, const QKeySequence &shortcut = 0)
/*!
\fn template<typename Functor> QAction *QMenu::addAction(const QString &text, Functor functor, const QKeySequence &shortcut)
\since 5.6
\obsolete
\overload
This convenience function creates a new action with the text \a
text and an optional shortcut \a shortcut. The action's
\l{QAction::triggered()}{triggered()} signal is connected to the
\a functor. The function adds the newly created
action to the menu's list of actions and returns it.
QMenu takes ownership of the returned QAction.
*/
/*!\fn template<typename Functor> QAction *QMenu::addAction(const QString &text, const QObject *context, Functor functor, const QKeySequence &shortcut)
\since 5.6
\overload
This convenience function creates a new action with the text \a
text and an optional shortcut \a shortcut. The action's
\l{QAction::triggered()}{triggered()} signal is connected to the
\a functor. The functor can be a pointer to a member function of
the \a context object. The newly created action is added to the
menu's list of actions and a pointer to it is returned.
If the \a context object is destroyed, the functor will not be called.
QMenu takes ownership of the returned QAction.
*/
/*!\fn template<typename Functor> QAction *QMenu::addAction(const QIcon &icon, const QString &text, Functor functor, const QKeySequence &shortcut = 0)
\since 5.6
\overload
This convenience function creates a new action with an \a icon
and some \a text and an optional shortcut \a shortcut. The action's
\l{QAction::triggered()}{triggered()} signal is connected to the
\a functor. The function adds the newly created
action to the menu's list of actions and returns it.
QMenu takes ownership of the returned QAction.
*/
/*!\fn template<typename Functor> QAction *QMenu::addAction(const QIcon &icon, const QString &text, const QObject *context, Functor functor, const QKeySequence &shortcut)
\since 5.6
\overload
This convenience function creates a new action with an \a icon
and some \a text and an optional shortcut \a shortcut. The action's
\l{QAction::triggered()}{triggered()} signal is connected to the
\a functor. The \a functor can be a pointer to a member function
of the \a context object. The newly created action is added to the
menu's list of actions and a pointer to it is returned.
If \a context is destroyed, the functor will not be called.
QMenu takes ownership of the returned QAction.
Use QWidget::addAction(text, shortcut, functor) instead.
*/
/*!
\overload
\fn template<typename Functor> QAction *QMenu::addAction(const QString &text, const QObject *context, Functor functor, const QKeySequence &shortcut)
This convenience function creates a new action with an \a icon and
some \a text and an optional shortcut \a shortcut. The action's
\l{QAction::triggered()}{triggered()} signal is connected to the
\a member slot of the \a receiver object. The function adds the
newly created action to the menu's list of actions, and returns it.
\since 5.6
\obsolete
QMenu takes ownership of the returned QAction.
\sa QWidget::addAction()
Use QWidget::addAction(text, shortcut, context, functor) instead.
*/
/*!
\fn template<typename Functor> QAction *QMenu::addAction(const QIcon &icon, const QString &text, Functor functor, const QKeySequence &shortcut)
\since 5.6
\obsolete
Use QWidget::addAction(icon, text, shortcut, functor) instead.
*/
/*!
\fn template<typename Functor> QAction *QMenu::addAction(const QIcon &icon, const QString &text, const QObject *context, Functor functor, const QKeySequence &shortcut)
\since 5.6
\obsolete
Use QWidget::addAction(icon, text, shortcut, context, functor) instead.
*/
/*!
\fn QAction *QMenu::addAction(const QIcon &icon, const QString &text, const QObject *receiver, const char* member, const QKeySequence &shortcut)
\obsolete
Use QWidget::addAction(icon, text, shortcut, receiver, member) instead.
*/
#if QT_CONFIG(shortcut)
QAction *QMenu::addAction(const QIcon &icon, const QString &text, const QObject *receiver,
const char* member
#if QT_CONFIG(shortcut)
, const QKeySequence &shortcut
#endif
)
const char* member, const QKeySequence &shortcut)
{
QAction *action = new QAction(icon, text, this);
#if QT_CONFIG(shortcut)
action->setShortcut(shortcut);
#endif
QObject::connect(action, SIGNAL(triggered(bool)), receiver, member);
addAction(action);
return action;
}
#endif
#endif // QT_DEPRECATED_SINCE(6, 4)
/*!
This convenience function adds \a menu as a submenu to this menu.

View File

@ -76,96 +76,71 @@ public:
~QMenu();
using QWidget::addAction;
#ifdef QT_BUILD_FUNCTIONS_REMOVED_IN_6_3
QAction *addAction(const QString &text);
QAction *addAction(const QIcon &icon, const QString &text);
#if !QT_CONFIG(shortcut)
QAction *addAction(const QString &text, const QObject *receiver, const char* member);
QAction *addAction(const QIcon &icon, const QString &text,
const QObject *receiver, const char* member);
#endif
#endif
QAction *addAction(const QString &text, const QObject *receiver, const char* member
#if QT_CONFIG(shortcut)
, const QKeySequence &shortcut = {}
#endif
);
QAction *addAction(const QIcon &icon, const QString &text, const QObject *receiver, const char* member
#if QT_CONFIG(shortcut)
, const QKeySequence &shortcut = {}
#endif
);
#if QT_DEPRECATED_SINCE(6, 4)
QT_DEPRECATED_VERSION_X_6_4("Use addAction(text, shortcut, receiver, member) instead.")
QAction *addAction(const QString &text, const QObject *receiver, const char* member,
const QKeySequence &shortcut);
QT_DEPRECATED_VERSION_X_6_4("Use addAction(icon, text, shortcut, receiver, member) instead.")
QAction *addAction(const QIcon &icon, const QString &text,
const QObject *receiver, const char* member,
const QKeySequence &shortcut);
#ifdef Q_CLANG_QDOC
template<typename Functor>
QAction *addAction(const QString &text, Functor functor, const QKeySequence &shortcut = 0);
QAction *addAction(const QString &text, Functor functor, const QKeySequence &shortcut);
template<typename Functor>
QAction *addAction(const QString &text, const QObject *context, Functor functor, const QKeySequence &shortcut = 0);
QAction *addAction(const QString &text, const QObject *context, Functor functor, const QKeySequence &shortcut);
template<typename Functor>
QAction *addAction(const QIcon &icon, const QString &text, Functor functor, const QKeySequence &shortcut = 0);
QAction *addAction(const QIcon &icon, const QString &text, Functor functor, const QKeySequence &shortcut);
template<typename Functor>
QAction *addAction(const QIcon &icon, const QString &text, const QObject *context, Functor functor, const QKeySequence &shortcut = 0);
QAction *addAction(const QIcon &icon, const QString &text, const QObject *context, Functor functor, const QKeySequence &shortcut);
#else
// addAction(QString): Connect to a QObject slot / functor or function pointer (with context)
template<class Obj, typename Func1>
inline typename std::enable_if<!std::is_same<const char*, Func1>::value
&& QtPrivate::IsPointerToTypeDerivedFromQObject<Obj*>::Value, QAction *>::type
addAction(const QString &text, const Obj *object, Func1 slot
#if QT_CONFIG(shortcut)
, const QKeySequence &shortcut = {}
#endif
)
addAction(const QString &text, const Obj *object, Func1 slot,
const QKeySequence &shortcut)
{
QAction *result = addAction(text);
#if QT_CONFIG(shortcut)
result->setShortcut(shortcut);
#endif
connect(result, &QAction::triggered, object, std::move(slot));
return result;
return addAction(text, shortcut, object, slot);
}
// addAction(QString): Connect to a functor or function pointer (without context)
template <typename Func1>
inline QAction *addAction(const QString &text, Func1 slot
#if QT_CONFIG(shortcut)
, const QKeySequence &shortcut = {}
#endif
)
inline QAction *addAction(const QString &text, Func1 slot, const QKeySequence &shortcut)
{
QAction *result = addAction(text);
#if QT_CONFIG(shortcut)
result->setShortcut(shortcut);
#endif
connect(result, &QAction::triggered, std::move(slot));
return result;
return addAction(text, shortcut, slot);
}
// addAction(QIcon, QString): Connect to a QObject slot / functor or function pointer (with context)
template<class Obj, typename Func1>
inline typename std::enable_if<!std::is_same<const char*, Func1>::value
&& QtPrivate::IsPointerToTypeDerivedFromQObject<Obj*>::Value, QAction *>::type
addAction(const QIcon &actionIcon, const QString &text, const Obj *object, Func1 slot
#if QT_CONFIG(shortcut)
, const QKeySequence &shortcut = {}
#endif
)
addAction(const QIcon &actionIcon, const QString &text, const Obj *object, Func1 slot,
const QKeySequence &shortcut)
{
QAction *result = addAction(actionIcon, text);
#if QT_CONFIG(shortcut)
result->setShortcut(shortcut);
#endif
connect(result, &QAction::triggered, object, std::move(slot));
return result;
return addAction(actionIcon, text, shortcut, object, slot);
}
// addAction(QIcon, QString): Connect to a functor or function pointer (without context)
template <typename Func1>
inline QAction *addAction(const QIcon &actionIcon, const QString &text, Func1 slot
#if QT_CONFIG(shortcut)
, const QKeySequence &shortcut = {}
#endif
)
inline QAction *addAction(const QIcon &actionIcon, const QString &text, Func1 slot,
const QKeySequence &shortcut)
{
QAction *result = addAction(actionIcon, text);
#if QT_CONFIG(shortcut)
result->setShortcut(shortcut);
#endif
connect(result, &QAction::triggered, std::move(slot));
return result;
return addAction(actionIcon, text, shortcut, slot);
}
#endif // !Q_CLANG_QDOC
#endif // QT_DEPRECATED_SINCE(6, 4)
#endif // QT_CONFIG(shortcut)
QAction *addMenu(QMenu *menu);
QMenu *addMenu(const QString &title);

View File

@ -736,117 +736,6 @@ void QToolBar::clear()
removeAction(actions.at(i));
}
/*!
Creates a new action with the given \a text. This action is added to
the end of the toolbar.
*/
QAction *QToolBar::addAction(const QString &text)
{
QAction *action = new QAction(text, this);
addAction(action);
return action;
}
/*!
\overload
Creates a new action with the given \a icon and \a text. This
action is added to the end of the toolbar.
*/
QAction *QToolBar::addAction(const QIcon &icon, const QString &text)
{
QAction *action = new QAction(icon, text, this);
addAction(action);
return action;
}
/*!
\overload
Creates a new action with the given \a text. This action is added to
the end of the toolbar. The action's \l{QAction::triggered()}{triggered()}
signal is connected to \a member in \a receiver.
*/
QAction *QToolBar::addAction(const QString &text,
const QObject *receiver, const char* member)
{
QAction *action = new QAction(text, this);
QObject::connect(action, SIGNAL(triggered(bool)), receiver, member);
addAction(action);
return action;
}
/*!
\overload
Creates a new action with the given \a icon and \a text. This
action is added to the end of the toolbar. The action's
\l{QAction::triggered()}{triggered()} signal is connected to \a
member in \a receiver.
*/
QAction *QToolBar::addAction(const QIcon &icon, const QString &text,
const QObject *receiver, const char* member)
{
QAction *action = new QAction(icon, text, this);
QObject::connect(action, SIGNAL(triggered(bool)), receiver, member);
addAction(action);
return action;
}
/*!\fn template<typename Functor> QAction *QToolBar::addAction(const QString &text, Functor functor)
\since 5.6
\overload
Creates a new action with the given \a text. This action is added to
the end of the toolbar. The action's
\l{QAction::triggered()}{triggered()} signal is connected to the
\a functor.
*/
/*!\fn template<typename Functor> QAction *QToolBar::addAction(const QString &text, const QObject *context, Functor functor)
\since 5.6
\overload
Creates a new action with the given \a text. This action is added
to the end of the toolbar. The action's
\l{QAction::triggered()}{triggered()} signal is connected to the
\a functor. The \a functor can be a pointer to a member function
in the \a context object.
If the \a context object is destroyed, the \a functor will not be called.
*/
/*!\fn template<typename Functor> QAction *QToolBar::addAction(const QIcon &icon, const QString &text, Functor functor)
\since 5.6
\overload
Creates a new action with the given \a icon and \a text. This
action is added to the end of the toolbar. The action's
\l{QAction::triggered()}{triggered()} signal is connected to the
\a functor.
*/
/*!\fn template<typename Functor> QAction *QToolBar::addAction(const QIcon &icon, const QString &text, const QObject *context, Functor functor)
\since 5.6
\overload
Creates a new action with the given \a icon and \a text. This
action is added to the end of the toolbar. The action's
\l{QAction::triggered()}{triggered()} signal is connected to the
\a functor. The \a functor can be a pointer to a member function
of the \a context object.
If the \a context object is destroyed, the \a functor will not be called.
*/
/*!
Adds a separator to the end of the toolbar.

View File

@ -90,58 +90,13 @@ public:
void clear();
using QWidget::addAction;
#ifdef QT_BUILD_FUNCTIONS_REMOVED_IN_6_3
QAction *addAction(const QString &text);
QAction *addAction(const QIcon &icon, const QString &text);
QAction *addAction(const QString &text, const QObject *receiver, const char* member);
QAction *addAction(const QIcon &icon, const QString &text,
const QObject *receiver, const char* member);
#ifdef Q_CLANG_QDOC
template<typename Functor>
QAction *addAction(const QString &text, Functor functor);
template<typename Functor>
QAction *addAction(const QString &text, const QObject *context, Functor functor);
template<typename Functor>
QAction *addAction(const QIcon &icon, const QString &text, Functor functor);
template<typename Functor>
QAction *addAction(const QIcon &icon, const QString &text, const QObject *context, Functor functor);
#else
// addAction(QString): Connect to a QObject slot / functor or function pointer (with context)
template<class Obj, typename Func1>
inline typename std::enable_if<!std::is_same<const char*, Func1>::value
&& QtPrivate::IsPointerToTypeDerivedFromQObject<Obj*>::Value, QAction *>::type
addAction(const QString &text, const Obj *object, Func1 slot)
{
QAction *result = addAction(text);
connect(result, &QAction::triggered, object, std::move(slot));
return result;
}
// addAction(QString): Connect to a functor or function pointer (without context)
template <typename Func1>
inline QAction *addAction(const QString &text, Func1 slot)
{
QAction *result = addAction(text);
connect(result, &QAction::triggered, slot);
return result;
}
// addAction(QString): Connect to a QObject slot / functor or function pointer (with context)
template<class Obj, typename Func1>
inline typename std::enable_if<!std::is_same<const char*, Func1>::value
&& QtPrivate::IsPointerToTypeDerivedFromQObject<Obj*>::Value, QAction *>::type
addAction(const QIcon &actionIcon, const QString &text, const Obj *object, Func1 slot)
{
QAction *result = addAction(actionIcon, text);
connect(result, &QAction::triggered, object, std::move(slot));
return result;
}
// addAction(QIcon, QString): Connect to a functor or function pointer (without context)
template <typename Func1>
inline QAction *addAction(const QIcon &actionIcon, const QString &text, Func1 slot)
{
QAction *result = addAction(actionIcon, text);
connect(result, &QAction::triggered, slot);
return result;
}
#endif // !Q_CLANG_QDOC
#endif
QAction *addSeparator();
QAction *insertSeparator(QAction *before);

View File

@ -0,0 +1,102 @@
/****************************************************************************
**
** Copyright (C) 2021 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Marc Mutz <marc.mutz@kdab.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 3 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL3 included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 3 requirements
** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 2.0 or (at your option) the GNU General
** Public license version 3 or any later version approved by the KDE Free
** Qt Foundation. The licenses are as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
** https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#define QT_BUILD_FUNCTIONS_REMOVED_IN_6_3
#include "qglobal.h"
QT_USE_NAMESPACE
#if QT_DEPRECATED_SINCE(6, 3)
#include "qmenu.h"
QAction *QMenu::addAction(const QString &text)
{
return QWidget::addAction(text);
}
QAction *QMenu::addAction(const QIcon &icon, const QString &text)
{
return QWidget::addAction(icon, text);
}
#if !QT_CONFIG(shortcut)
// the overloads taking QKeySequence as a trailing argument are deprecated, not removed,
// so remained in qmenu.cpp
QAction *QMenu::addAction(const QString &text, const QObject *receiver, const char* member)
{
return QWidget::addAction(text, receiver, member);
}
QAction *QMenu::addAction(const QIcon &icon, const QString &text,
const QObject *receiver, const char* member)
{
return QWidget::addAction(icon, text, receiver, member);
}
#endif
#include "qtoolbar.h"
QAction *QToolBar::addAction(const QString &text)
{
return QWidget::addAction(text);
}
QAction *QToolBar::addAction(const QIcon &icon, const QString &text)
{
return QWidget::addAction(icon, text);
}
QAction *QToolBar::addAction(const QString &text,
const QObject *receiver, const char* member)
{
return QWidget::addAction(text, receiver, member);
}
QAction *QToolBar::addAction(const QIcon &icon, const QString &text,
const QObject *receiver, const char* member)
{
return QWidget::addAction(icon, text, receiver, member);
}
// #include <qotherheader.h>
// // implement removed functions from qotherheader.h
#endif // QT_DEPRECATED_SINCE(6, 3)

View File

@ -304,6 +304,9 @@ void tst_QMenu::addActionsConnect()
menu.addAction(icon, text, &menu, testFunction);
#ifndef QT_NO_SHORTCUT
const QKeySequence keySequence(Qt::CTRL | Qt::Key_C);
#if QT_DEPRECATED_SINCE(6, 4)
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
menu.addAction(text, &menu, SLOT(deleteLater()), keySequence);
menu.addAction(text, &menu, &QMenu::deleteLater, keySequence);
menu.addAction(text, testFunction, keySequence);
@ -312,6 +315,16 @@ void tst_QMenu::addActionsConnect()
menu.addAction(icon, text, &menu, &QMenu::deleteLater, keySequence);
menu.addAction(icon, text, testFunction, keySequence);
menu.addAction(icon, text, &menu, testFunction, keySequence);
QT_WARNING_POP
#endif
menu.addAction(text, keySequence, &menu, SLOT(deleteLater()));
menu.addAction(text, keySequence, &menu, &QMenu::deleteLater);
menu.addAction(text, keySequence, testFunction);
menu.addAction(text, keySequence, &menu, testFunction);
menu.addAction(icon, text, keySequence, &menu, SLOT(deleteLater()));
menu.addAction(icon, text, keySequence, &menu, &QMenu::deleteLater);
menu.addAction(icon, text, keySequence, testFunction);
menu.addAction(icon, text, keySequence, &menu, testFunction);
#endif // !QT_NO_SHORTCUT
}