Details
-
Bug
-
Resolution: Done
-
P1: Critical
-
5.15.0 Alpha
-
None
-
-
e1920f65936fe7d712441e88c023746ab5c21cee (qt/qtbase/5.15)
Description
Calls to "new QShortcut" fail to compile with Qt 5.15.0-alpha.
Simple (and trimmed down to the point that it is bogus, but still shows the error) test case:
#include <QShortcut> #include <QKeySequence> int main(int argc, char **argv) { QShortcut x(QKeySequence(QObject::tr("Ctrl+L", "File|Load")), nullptr, SLOT(someSlotHere()), nullptr); }
Result:
In file included from test.cpp:1: In file included from /usr/include/qt5/QtWidgets/QShortcut:1: /usr/include/qt5/QtWidgets/qshortcut.h:101:9: error: no matching member function for call to 'connect' connect(this, &QShortcut::activated, object1, std::move(slot1)); ^~~~~~~ test.cpp:4:12: note: in instantiation of function template specialization 'QShortcut::QShortcut<char, nullptr_t>' requested here QShortcut x(QKeySequence(QObject::tr("Ctrl+L", "File|Load")), nullptr, SLOT(someSlotHere()), nullptr); ^ /usr/include/qt5/QtCore/qobject.h:283:13: note: candidate function template not viable: no known conversion from 'const char *' to 'const QObject *' for 3rd argument connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal, const QObject *context, Func2 slot, ^ /usr/include/qt5/QtCore/qobject.h:322:13: note: candidate function template not viable: no known conversion from 'const char *' to 'const QObject *' for 3rd argument connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal, const QObject *context, Func2 slot, ^ /usr/include/qt5/QtCore/qobject.h:222:36: note: candidate function not viable: no known conversion from 'void (QShortcut::*)()' to 'const char *' for 2nd argument static QMetaObject::Connection connect(const QObject *sender, const char *signal, ^ /usr/include/qt5/QtCore/qobject.h:481:41: note: candidate function not viable: no known conversion from 'void (QShortcut::*)()' to 'const char *' for 2nd argument inline QMetaObject::Connection QObject::connect(const QObject *asender, const char *asignal, ^ /usr/include/qt5/QtCore/qobject.h:225:36: note: candidate function not viable: no known conversion from 'void (QShortcut::*)()' to 'const QMetaMethod' for 2nd argument static QMetaObject::Connection connect(const QObject *sender, const QMetaMethod &signal, ^ /usr/include/qt5/QtCore/qobject.h:242:43: note: candidate template ignored: substitution failure [with Func1 = void (QShortcut::*)(), Func2 = nullptr_t]: no type named 'Object' in 'QtPrivate::FunctionPointer<nullptr_t>' static inline QMetaObject::Connection connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal, ^ /usr/include/qt5/QtCore/qobject.h:274:13: note: candidate function template not viable: requires 3 arguments, but 4 were provided connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal, Func2 slot) ^ /usr/include/qt5/QtCore/qobject.h:314:13: note: candidate function template not viable: requires 3 arguments, but 4 were provided connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal, Func2 slot) ^ 1 error generated.
Real world (and valid) uses of QShortcut that break can be found in KDE lokalize 19.12.2 and kvirc (with WebKit enabled).
Tested with clang 10.0-rc2 and a current gcc 10 snapshot.
Workaround:
Passing any slot (valid or not) instead of nullptr or 0 as ambiguousMember works
Attachments
Issue Links
- resulted from
-
QTBUG-77816 QShortcut has no PointerToMemberFunction overload for the receiver
- Closed