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. QRadioButton, calling setChecked doesn't emit a signal
Forum Updated to NodeBB v4.3 + New Features

QRadioButton, calling setChecked doesn't emit a signal

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 2.0k 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

    Why doesn't calling setChecked on a radio button emit the clicked signal or any other signal?

    I found this out and have to call emit clicked(true) after calling setChecked(true).

    It also seems that calling emit clicked(true) on its own does not cause the radio button to be selected.

    Kind Regards,
    Sy

    JonBJ 1 Reply Last reply
    0
    • SPlattenS SPlatten

      @JonB , thank you, I'm just not seeing this, I have a slot connected to clicked:

          cn = QObject::connect(this, &clsQtRadioButton::clicked
                               ,this, &clsQtRadioButton::rptrClicked);
      

      My slot:

      void clsQtRadioButton::rptrClicked(bool blnChecked) {
          QJsonObject objJSON;
          if ( mpobjNode->blnCheckSubscribers(clsQtRadioButton::mscszQtSignalClicked
                                             ,&objJSON) == true ) {
              QJsonObject objParam;
              objParam[clsXMLnode::mscszAttrChecked] = blnChecked;
              objJSON[clsXMLnode::mscszAttrParameters] = objParam;
              emit mpobjNode->commonRptdSignal(objJSON);
          }
          QString strID = mpobjNode->strGetAttribute(clsXMLnode::mscszAttrID)
                 ,strData = mpobjNode->strGetAttribute(clsXMLnode::mscszAttrText);
          objJSON.insert(clsXMLnode::mscszAttrID, strID);
          objJSON.insert(clsXMLnode::mscszAttrSignal, clsQtRadioButton::mscszQtSignalClicked);
          objJSON.insert(clsXMLnode::mscszAttrData, strData);
          clsXMLnode* pobjWindow(mpobjNode->pobjGetWindow());
          clsXMLnode::blnSaveModified(objJSON, pobjWindow);
      }
      

      It doesn't get called, unless as I said I call emit clicked(true); myself.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #4

      @SPlatten said in QRadioButton, calling setChecked doesn't emit a signal:

      , I have a slot connected to clicked:

      ? But I said the signal is toggled(), not clicked().

      1 Reply Last reply
      1
      • SPlattenS SPlatten

        Why doesn't calling setChecked on a radio button emit the clicked signal or any other signal?

        I found this out and have to call emit clicked(true) after calling setChecked(true).

        It also seems that calling emit clicked(true) on its own does not cause the radio button to be selected.

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by JonB
        #2

        @SPlatten
        void QAbstractButton::toggled(bool checked)

        This signal is emitted whenever a checkable button changes its state. checked is true if the button is checked, or false if the button is unchecked.

        This may be the result of a user action, click() slot activation, or because setChecked() is called.

        Doc for setChecked(bool) tells you this:

        Notifier signal:

        void toggled(bool checked)

        SPlattenS 1 Reply Last reply
        0
        • JonBJ JonB

          @SPlatten
          void QAbstractButton::toggled(bool checked)

          This signal is emitted whenever a checkable button changes its state. checked is true if the button is checked, or false if the button is unchecked.

          This may be the result of a user action, click() slot activation, or because setChecked() is called.

          Doc for setChecked(bool) tells you this:

          Notifier signal:

          void toggled(bool checked)

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

          @JonB , thank you, I'm just not seeing this, I have a slot connected to clicked:

              cn = QObject::connect(this, &clsQtRadioButton::clicked
                                   ,this, &clsQtRadioButton::rptrClicked);
          

          My slot:

          void clsQtRadioButton::rptrClicked(bool blnChecked) {
              QJsonObject objJSON;
              if ( mpobjNode->blnCheckSubscribers(clsQtRadioButton::mscszQtSignalClicked
                                                 ,&objJSON) == true ) {
                  QJsonObject objParam;
                  objParam[clsXMLnode::mscszAttrChecked] = blnChecked;
                  objJSON[clsXMLnode::mscszAttrParameters] = objParam;
                  emit mpobjNode->commonRptdSignal(objJSON);
              }
              QString strID = mpobjNode->strGetAttribute(clsXMLnode::mscszAttrID)
                     ,strData = mpobjNode->strGetAttribute(clsXMLnode::mscszAttrText);
              objJSON.insert(clsXMLnode::mscszAttrID, strID);
              objJSON.insert(clsXMLnode::mscszAttrSignal, clsQtRadioButton::mscszQtSignalClicked);
              objJSON.insert(clsXMLnode::mscszAttrData, strData);
              clsXMLnode* pobjWindow(mpobjNode->pobjGetWindow());
              clsXMLnode::blnSaveModified(objJSON, pobjWindow);
          }
          

          It doesn't get called, unless as I said I call emit clicked(true); myself.

          Kind Regards,
          Sy

          JonBJ 1 Reply Last reply
          0
          • SPlattenS SPlatten

            @JonB , thank you, I'm just not seeing this, I have a slot connected to clicked:

                cn = QObject::connect(this, &clsQtRadioButton::clicked
                                     ,this, &clsQtRadioButton::rptrClicked);
            

            My slot:

            void clsQtRadioButton::rptrClicked(bool blnChecked) {
                QJsonObject objJSON;
                if ( mpobjNode->blnCheckSubscribers(clsQtRadioButton::mscszQtSignalClicked
                                                   ,&objJSON) == true ) {
                    QJsonObject objParam;
                    objParam[clsXMLnode::mscszAttrChecked] = blnChecked;
                    objJSON[clsXMLnode::mscszAttrParameters] = objParam;
                    emit mpobjNode->commonRptdSignal(objJSON);
                }
                QString strID = mpobjNode->strGetAttribute(clsXMLnode::mscszAttrID)
                       ,strData = mpobjNode->strGetAttribute(clsXMLnode::mscszAttrText);
                objJSON.insert(clsXMLnode::mscszAttrID, strID);
                objJSON.insert(clsXMLnode::mscszAttrSignal, clsQtRadioButton::mscszQtSignalClicked);
                objJSON.insert(clsXMLnode::mscszAttrData, strData);
                clsXMLnode* pobjWindow(mpobjNode->pobjGetWindow());
                clsXMLnode::blnSaveModified(objJSON, pobjWindow);
            }
            

            It doesn't get called, unless as I said I call emit clicked(true); myself.

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by
            #4

            @SPlatten said in QRadioButton, calling setChecked doesn't emit a signal:

            , I have a slot connected to clicked:

            ? But I said the signal is toggled(), not clicked().

            1 Reply Last reply
            1

            • Login

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