QRadioButton, calling setChecked doesn't emit a signal
-
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.
-
@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.
-
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.
@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)
-
@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)
@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.
-
@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.