I’ve made simple Qt4 design and I want to make it work with c++ but I’ve got problem with QT4 radio buttons. I have text field, two radio buttons and a submit button. I want when the submit button is clicked to check which radio button is checked and what is the information in the text field. I’m getting the text field info but I can’t find how to check which radio button is check if any is checked.
Share
Radio buttons are mutually exclusive within a radio button group. By default, radio buttons are part of the same group if they have the same parent.
Make sure one of your radio buttons is checked at start up either by checking one in your UI designer or at start up in code.
When your submit button is clicked, check each radio button by calling
radioButtonName.isChecked().When looking at Qt documentation, don’t forget to look at the documentation for the entire inheritance hierarchy for a class. The
isChecked()function is documented way up in theQAbstractButtonclass as this state is valid for many different button sub classes 🙂