How to find out which radio button chosen by the user

Lion King

I have four radio buttons, the user must choose one of the four radio buttons.

The problem is each radio button has its own name differs from the other.

How to find out which radio button chosen by the user ?

Kosovan

Add the buttons into a GroupBox and use findChildren, after this you can use QButtonGroup or simply iterate through all Buttons list and check name of radiobutton. It is efficient way because it works with 4 button or 1000, you should write big code if you have many buttons.

void MainWindow::on_pushButton_15_clicked(){
    QButtonGroup group;
    QList<QRadioButton *> allButtons = ui->groupBox->findChildren<QRadioButton *>();
    qDebug() <<allButtons.size();
    for(int i = 0; i < allButtons.size(); ++i)
    {
        group.addButton(allButtons[i],i);
    }
    qDebug() << group.checkedId();
    qDebug() << group.checkedButton();
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

How to find out which microphone device user gave permission to?

From Java

Find out whether radio button is checked with JQuery?

From Java

Configure a button that links to site depending on chosen radio button

From Dev

How do I find out which string resource is currently assigned to the android:text property of a button view?

From Dev

how to find checked radio button in a gridview?

From Dev

How to know which radio button is selected in jquery?

From Dev

Correct syntax for disabling a radio button after it was chosen

From Dev

how to know which radio button id selected of which row?

From Dev

How to confirm the chosen radio button?

From Dev

How to enable chosen selectbox which is already disabled on button click in jquery?

From Dev

how could i collect all the radio button that chosen in submit button?

From Dev

How to find out which radio button the user selected in Javascript?

From Dev

How do I figure out which font file is chosen for a system generic font alias?

From Dev

Find out which UITableView the button belongs to

From Dev

how to find checked radio button in a gridview?

From Dev

How do you set a value in codebehind depending on which radio button is chosen?

From Dev

Way to find out which button the user selected on the UIAlertView displayed by iOS ,asking permission to allow the app to receive push notification

From Dev

How to post out the value of a radio button into MySQL

From Dev

Correct syntax for disabling a radio button after it was chosen

From Dev

Find which input radio button is checked in code behind

From Dev

How to find out which package a user belongs to?

From Dev

How to switch a radio button out with a glyphicon

From Dev

PHP and Ajax: how to find out which object did the user click to pass to php?

From Dev

How to find out which USB is which on a BBB

From Dev

How can I find out which user deleted a directory?

From Dev

how to check which radio button is checked in android?

From Dev

How to find out which user is using a particular display language in Windows 8.1

From Dev

how to know which radio button is selected out of all options?

From Dev

Allow user to select only one radio button out of many

Related Related

  1. 1

    How to find out which microphone device user gave permission to?

  2. 2

    Find out whether radio button is checked with JQuery?

  3. 3

    Configure a button that links to site depending on chosen radio button

  4. 4

    How do I find out which string resource is currently assigned to the android:text property of a button view?

  5. 5

    how to find checked radio button in a gridview?

  6. 6

    How to know which radio button is selected in jquery?

  7. 7

    Correct syntax for disabling a radio button after it was chosen

  8. 8

    how to know which radio button id selected of which row?

  9. 9

    How to confirm the chosen radio button?

  10. 10

    How to enable chosen selectbox which is already disabled on button click in jquery?

  11. 11

    how could i collect all the radio button that chosen in submit button?

  12. 12

    How to find out which radio button the user selected in Javascript?

  13. 13

    How do I figure out which font file is chosen for a system generic font alias?

  14. 14

    Find out which UITableView the button belongs to

  15. 15

    how to find checked radio button in a gridview?

  16. 16

    How do you set a value in codebehind depending on which radio button is chosen?

  17. 17

    Way to find out which button the user selected on the UIAlertView displayed by iOS ,asking permission to allow the app to receive push notification

  18. 18

    How to post out the value of a radio button into MySQL

  19. 19

    Correct syntax for disabling a radio button after it was chosen

  20. 20

    Find which input radio button is checked in code behind

  21. 21

    How to find out which package a user belongs to?

  22. 22

    How to switch a radio button out with a glyphicon

  23. 23

    PHP and Ajax: how to find out which object did the user click to pass to php?

  24. 24

    How to find out which USB is which on a BBB

  25. 25

    How can I find out which user deleted a directory?

  26. 26

    how to check which radio button is checked in android?

  27. 27

    How to find out which user is using a particular display language in Windows 8.1

  28. 28

    how to know which radio button is selected out of all options?

  29. 29

    Allow user to select only one radio button out of many

HotTag

Archive