Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QButtonGroup signals
Qt 6.11 is out! See what's new in the release blog

QButtonGroup signals

Scheduled Pinned Locked Moved Solved General and Desktop
10 Posts 3 Posters 1.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • SPlattenS Offline
    SPlattenS Offline
    SPlatten
    wrote on last edited by SPlatten
    #1

    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)
                ^
    

    Kind Regards,
    Sy

    jsulmJ 1 Reply Last reply
    0
    • SPlattenS SPlatten

      @jsulm said in QButtonGroup signals:

      https://doc.qt.io/qt-5/qbuttongroup.html#buttonClicked

      Thank you, ok that makes a lot of sense, however the documentation:
      https://doc.qt.io/qt-5/qbuttongroup.html#signals

      Clicking on Signals on the left:
      https://doc.qt.io/qt-5/qbuttongroup.html#signals

      It isn't clear at all that there are multiple (overloaded) versions of the signal.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #6

      @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.html

      You can file a bug for documentation if you like.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      SPlattenS 2 Replies Last reply
      3
      • SPlattenS SPlatten

        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)
                    ^
        
        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #2

        @SPlatten said in QButtonGroup signals:

        however QObject::connect is underlined in red

        And what does the error message say?

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        SPlattenS 1 Reply Last reply
        0
        • jsulmJ jsulm

          @SPlatten said in QButtonGroup signals:

          however QObject::connect is underlined in red

          And what does the error message say?

          SPlattenS Offline
          SPlattenS Offline
          SPlatten
          wrote on last edited by
          #3

          @jsulm sorry, please see edited post.

          Kind Regards,
          Sy

          jsulmJ 1 Reply Last reply
          0
          • SPlattenS SPlatten

            @jsulm sorry, please see edited post.

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #4

            @SPlatten buttonClicked is overloaded.
            It is shown in the documentation how to connect it: https://doc.qt.io/qt-5/qbuttongroup.html#buttonClicked

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            SPlattenS 1 Reply Last reply
            1
            • jsulmJ jsulm

              @SPlatten buttonClicked is overloaded.
              It is shown in the documentation how to connect it: https://doc.qt.io/qt-5/qbuttongroup.html#buttonClicked

              SPlattenS Offline
              SPlattenS Offline
              SPlatten
              wrote on last edited by
              #5

              @jsulm said in QButtonGroup signals:

              https://doc.qt.io/qt-5/qbuttongroup.html#buttonClicked

              Thank you, ok that makes a lot of sense, however the documentation:
              https://doc.qt.io/qt-5/qbuttongroup.html#signals

              Clicking on Signals on the left:
              https://doc.qt.io/qt-5/qbuttongroup.html#signals

              It isn't clear at all that there are multiple (overloaded) versions of the signal.

              Kind Regards,
              Sy

              jsulmJ 1 Reply Last reply
              0
              • SPlattenS SPlatten

                @jsulm said in QButtonGroup signals:

                https://doc.qt.io/qt-5/qbuttongroup.html#buttonClicked

                Thank you, ok that makes a lot of sense, however the documentation:
                https://doc.qt.io/qt-5/qbuttongroup.html#signals

                Clicking on Signals on the left:
                https://doc.qt.io/qt-5/qbuttongroup.html#signals

                It isn't clear at all that there are multiple (overloaded) versions of the signal.

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #6

                @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.html

                You can file a bug for documentation if you like.

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                SPlattenS 2 Replies Last reply
                3
                • jsulmJ jsulm

                  @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.html

                  You can file a bug for documentation if you like.

                  SPlattenS Offline
                  SPlattenS Offline
                  SPlatten
                  wrote on last edited by
                  #7

                  @jsulm , will do.

                  Kind Regards,
                  Sy

                  1 Reply Last reply
                  1
                  • jsulmJ jsulm

                    @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.html

                    You can file a bug for documentation if you like.

                    SPlattenS Offline
                    SPlattenS Offline
                    SPlatten
                    wrote on last edited by
                    #8

                    @jsulm said in QButtonGroup signals:

                    https://code.woboq.org/qt5/qtbase/src/widgets/widgets/qbuttongroup.h.html

                    https://bugreports.qt.io/browse/QTCREATORBUG-26552

                    Kind Regards,
                    Sy

                    J.HilkJ 1 Reply Last reply
                    2
                    • SPlattenS SPlatten

                      @jsulm said in QButtonGroup signals:

                      https://code.woboq.org/qt5/qtbase/src/widgets/widgets/qbuttongroup.h.html

                      https://bugreports.qt.io/browse/QTCREATORBUG-26552

                      J.HilkJ Offline
                      J.HilkJ Offline
                      J.Hilk
                      Moderators
                      wrote on last edited by
                      #9

                      @SPlatten to be fair,
                      its is mentioned
                      https://doc.qt.io/qt-5/qbuttongroup.html#buttonClicked
                      b6179bd4-eeef-4546-b386-425f8a4ac140-image.png


                      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                      Q: What's that?
                      A: It's blue light.
                      Q: What does it do?
                      A: It turns blue.

                      SPlattenS 1 Reply Last reply
                      0
                      • J.HilkJ J.Hilk

                        @SPlatten to be fair,
                        its is mentioned
                        https://doc.qt.io/qt-5/qbuttongroup.html#buttonClicked
                        b6179bd4-eeef-4546-b386-425f8a4ac140-image.png

                        SPlattenS Offline
                        SPlattenS Offline
                        SPlatten
                        wrote on last edited by SPlatten
                        #10

                        @J-Hilk , yes, if you know where to look but it isn't very clear on the signals page, unless you scroll down.

                        Kind Regards,
                        Sy

                        1 Reply Last reply
                        0

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved