QButtonGroup signals
-
I have derived a class from QButtonGroup, the prototype:
class clsQtButtonGrp : public QButtonGroup { Q_OBJECT friend class clsXMLnode; private: static mpSignals mscmpSignals; clsXMLnode* mpobjNode; public: static const char mscszQtSignalClicked[]; static const char mscszQtSignalPressed[]; static const char mscszQtSignalReleased[]; static const char mscszQtSignalToggled[]; explicit clsQtButtonGrp(clsXMLnode* pobjNode, QWidget* parent = nullptr); static bool blnValidSignal(QString strSignal); QMetaObject::Connection connect(clsSignal* pobjSignal ,clsXMLnode* pobjSubscriber ,QJSEngine* pobjScriptEng = nullptr ,QString strScript = ""); static mpSignals* pmpGetSignals() { return &clsQtButtonGrp::mscmpSignals; } private slots: void rptrClicked(QAbstractButton* pobjButton); void rptrPressed(QAbstractButton* pobjButton); void rptrReleased(QAbstractButton* pobjButton); void rptrToggled(QAbstractButton* pobjButton, bool blnChecked); void setupControl(const QJsonObject& crobjJSON); signals: public slots: };
In my constructor I connect the signals to the repeater slots in the class, however QObject::connect is underlined in red.
QMetaObject::Connection cn; cn = QObject::connect(this, &clsQtButtonGrp::buttonClicked ,this, &clsQtButtonGrp::rptrClicked); Q_ASSERT_X(cn, scszQtButtonGrp ,scstrAssert.arg(clsQtButtonGrp::mscszQtSignalClicked) .toLatin1().data());
Why?
Just one of 22 errors:
/Users/sy/XMLMPAM/clsQtButtonGrp.cpp:46: error: no matching member function for call to 'connect' ../clsQtButtonGrp.cpp:46:19: error: no matching member function for call to 'connect' cn = QObject::connect(this, &clsQtButtonGrp::buttonPressed ~~~~~~~~~^~~~~~~ ../../Qt/5.15.2/clang_64/lib/QtCore.framework/Headers/qobject.h:222:36: note: candidate function not viable: no overload of 'buttonPressed' matching 'const char *' for 2nd argument static QMetaObject::Connection connect(const QObject *sender, const char *signal, ^ ../../Qt/5.15.2/clang_64/lib/QtCore.framework/Headers/qobject.h:225:36: note: candidate function not viable: no overload of 'buttonPressed' matching 'const QMetaMethod' for 2nd argument static QMetaObject::Connection connect(const QObject *sender, const QMetaMethod &signal, ^ ../../Qt/5.15.2/clang_64/lib/QtCore.framework/Headers/qobject.h:481:41: note: candidate function not viable: no overload of 'buttonPressed' matching 'const char *' for 2nd argument inline QMetaObject::Connection QObject::connect(const QObject *asender, const char *asignal, ^ ../../Qt/5.15.2/clang_64/lib/QtCore.framework/Headers/qobject.h:242:43: note: candidate template ignored: couldn't infer template argument 'Func1' static inline QMetaObject::Connection connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal, ^ ../../Qt/5.15.2/clang_64/lib/QtCore.framework/Headers/qobject.h:283:13: note: candidate template ignored: couldn't infer template argument 'Func1' connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal, const QObject *context, Func2 slot, ^ ../../Qt/5.15.2/clang_64/lib/QtCore.framework/Headers/qobject.h:322:13: note: candidate template ignored: couldn't infer template argument 'Func1' connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal, const QObject *context, Func2 slot, ^ ../../Qt/5.15.2/clang_64/lib/QtCore.framework/Headers/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) ^ ../../Qt/5.15.2/clang_64/lib/QtCore.framework/Headers/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) ^
-
@SPlatten Yes, it looks like void buttonClicked(int); isn't mentioned in the documentation. I was also wondering why one would need to specify which overload to use if there is only one :-)
So, I checked the code: https://code.woboq.org/qt5/qtbase/src/widgets/widgets/qbuttongroup.h.htmlYou can file a bug for documentation if you like.
-
@SPlatten said in QButtonGroup signals:
however QObject::connect is underlined in red
And what does the error message say?
-
@SPlatten buttonClicked is overloaded.
It is shown in the documentation how to connect it: https://doc.qt.io/qt-5/qbuttongroup.html#buttonClicked -
@jsulm said in QButtonGroup signals:
Thank you, ok that makes a lot of sense, however the documentation:
https://doc.qt.io/qt-5/qbuttongroup.html#signalsClicking on Signals on the left:
https://doc.qt.io/qt-5/qbuttongroup.html#signalsIt isn't clear at all that there are multiple (overloaded) versions of the signal.
-
@SPlatten Yes, it looks like void buttonClicked(int); isn't mentioned in the documentation. I was also wondering why one would need to specify which overload to use if there is only one :-)
So, I checked the code: https://code.woboq.org/qt5/qtbase/src/widgets/widgets/qbuttongroup.h.htmlYou can file a bug for documentation if you like.
-
-
@SPlatten to be fair,
its is mentioned
https://doc.qt.io/qt-5/qbuttongroup.html#buttonClicked