I am finding issues related to check/uncheck of QRadioButton. The images I have used for checking(a white dot) and unchecking(without a white dot) is not updated. My issue is like: I have implemented few QRadioButton(s). For the first time all the QRadioButtons checked false. So the images for this case is without a white dot. When user selects any QRadioButton then it's image changes to another i.e. image with a white dot. On a button click I am resetting the state of the radio buttons from checked to uncheck state . However the images state are not changing. They remain in checked state. The code snippet is as follows:
Code:
if(ui->radioButtonReadOnlineData->isChecked())
ui->radioButtonReadOnlineData->setChecked(false);
if(ui->radioButtonSavetoDBReadOfflineData->isChecked())
ui->radioButtonSavetoDBReadOfflineData->setChecked(false);
if(ui->radioButtonViewLocalData->isChecked())
ui->radioButtonViewLocalData->setChecked(false);
if(ui->radioButtonDateRange->isChecked())
ui->radioButtonDateRange->setChecked(false);
if(ui->radioButtonAll->isChecked())
ui->radioButtonAll->setChecked(false);
The images for each of the QRadioButtons is set as like:
Code:
ui->radioButtonAll->setStyleSheet(
"QRadioButton::indicator::checked { image: url(:/Resources/radio-btn-selected.png);}"
"QRadioButton::indicator::unchecked {image: url(:/Resources/radio-btn-unselected.png);}"
);
Any clues why the QRradioButton images are not updated. Thanks.
Your problem is most probably related to
setAutoExclusive(bool)
By default all buttons belonging to the same parent behave as if they were part of the same exclusive button group. After having selected one you are not able to return to having all buttons unchecked.
A work around is to find out what button is checked, and for that button do the following
theSelectedButton->setAutoExclusive(false);
thsSelectedButton->setChecked(false);
theSelectedButton->setAutoExclusive(true);
Take a look at these links for more information:
http://developer.qt.nokia.com/forums/viewthread/5482
http://www.qtforum.org/article/19619/qradiobutton-setchecked-bug.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With