PDA

View Full Version : combobox



Aasikaa
25th July 2018, 10:59
How to automatically change the options in a second combobox based on the option chosen(output) in the first combobox.

Added after 27 minutes:

I want the answer in python

tuli
25th July 2018, 11:09
by connecting the first comboxes currentIndexChanged(int) signal to the second ones setCurrentIndex(int) slot

d_stranz
26th July 2018, 01:03
That works if you want the items with the same indexes to be chosen in each combobox. I think what the OP means is that the second combobox will be filled with a different list of items based on what was chosen in the first box.

The more general solution is to write a slot that listens for the currentIndexChanged() signal. In that slot, you clear the second combobox and fill it with the correct items for whatever index was chosen in the first combobox.

If I were to do this in python, I would create a list of lists; the first list would be index numbers from 0 to whatever. For each entry in that list, it would contain a sub-list of the entries for the second combobox. In the slot, you retrieve the sub-list for the index that was selected, and use it to fill the second combobox.

If you can't hard-code the second combobox lists, then you'll have to use some other means to look up or retrieve the second list based on the first index.

Aasikaa
26th July 2018, 05:49
Thank you. will try these