All of the answers I have found say just to use a dictionary or a list. I am making an application and the GUI is being design in QT creator. There is an array of checkboxes(21) and in Qt Creator are all labeled cb0....cb20. I have a 21 element list that represents if the checkbox should be checked or not. Is there a way to loop through variable names? Pseudo code:
for i in range(21):
if cbList[i]:
cb'i'.setChecked=True
else:
cb'i'.setChecked=False
How can I have cb'i' translate the i into the variable name?
Added for clarity:
I don't want to create a dictionary and then set the dictionary value true or false. The variables already exist. They are checkboxes in the GUI. All the checkboxes are name cb0 ... cb20. They have the function setChecked that i wish to call for each instance of the checkbox. For example cb0.setChecked(False) will disable the checkbox. I have a list that corresponds to each checkbox. I am trying to avoid writing cb1.setChecked(True) for all 21 checkboxes.