Nominate our 2022 Qt Champions!

Validating a multiple checkboes

  • Hi,
    I am new programmer in Qt and i am using Qt-4.7.4 to do my programming,i have created around 32 check boxes by using Qt-Creator and when ever an check box is selected i am changing the color of the check box by using the setStyleSheet to green method and clearing the tick mark of the check box.If the user again tries to select the checkbox that was in green color then i should warn him that the checkbox was already selected.To do this instead of checking all the check boxes individually i am trying to iterate them in a loop but i am unsuccessful to do by using a loop.I have changed the names of check box in the following way
    for FIRST CheckBox name is ch_1 and for second CheckBox name is ch_2 till ch_32.
    How should store these 32 objects of the checkboxes into an list or an vector.Please explain me with a sample code.
    Please guide me
    Thanks in advance,

  • Lifetime Qt Champion

    There is no need to check all check boxes if one of them is clicked.
    Just connect the clicked(bool checked = false) signal to a slot.
    In that slot you get the pointer to the clicked check box using sender().

  • I am not really sure what you want to do, but maybe a QButtonGroup could be helpful?

Log in to reply