-1

i'm basically trying to add values 1-100 in combo box but i'm unable to do so

for i in range(1,100):
    rollno_list = []
    rollno_list.append(i)

combo_roll = QComboBox()
combo_roll.addItems([str(rollno_list)])
eyllanesc
  • 235,170
  • 19
  • 170
  • 241
  • Please add some error logs and explain what issue are you facing. This will help users to help you! – Gugu72 May 23 '21 at 09:44

2 Answers2

1

You are adding a list with a single element that is a string, instead you must convert each element to a string:

combo_roll.addItems([str(e) for e in range(1, 100)])

Also in the for-loop you are creating a list in each iteration where you add a new element which is an error.

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
-1

You are initialising rollno_list inside the for loop so basically at the end of for loop there is only one number in your list.

rollno_list = []
for i in range(1,100):

    rollno_list.append(i)

combo_roll = QComboBox()
combo_roll.addItems([str(rollno_list)])
Pavan Sai
  • 127
  • 2
  • 11