Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Iterate through multiple combo boxes in a container pyqt

I’m having a problem with extracting data from multiple comboboxes at once. I have around 10 comboboxes in a container. I could extract the data individual but that would result in repeated code.
This is what I have so far but doesn’t seem to work at all:

  def extractData():
     window.survey= window.surveyContainer.currentText()
  for results in window.surveryContainer.children():    
     results.currentTextChanged.connect(extractData)

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

First of all you will need to have all the comboboxes you want to access on the same container (in this case I assume it is surveryContainer), then you can do:

for results in window.surveryContainer.findChildren(QComboBox):    
   results.currentTextChanged.connect(extractData)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading