Add list to ComboBox

0

When I try to add lstSection to the ComboBox, I have the following error.

  

Error: addItem (self, str, userData: Any = None): argument 1 has   unexpected type 'list' addItem (self, QIcon, str, userData: Any =   None): argument 1 has unexpected type 'list'

Code:

self.dlg.comboBox.addItem(lstSeccion)

Seal information:

['Situacion', 'Contexto', 'Detalle', 'Observacion']
    
asked by Sebastian 07.09.2018 в 14:16
source

1 answer

0

You have two options. Either you make addItems as suggested by @FJSevilla, or you can use a loop (although it is not the most appropriate, unless you want to get the information from dictionaries, database records or more complicated places).

without loop:

lstSeccion = ['Situacion', 'Contexto', 'Detalle', 'Observacion']
self.dlg.comboBox.addItems(lstSeccion)

with loop:

lstSeccion = ['Situacion', 'Contexto', 'Detalle', 'Observacion']
for i in lstSeccion:
    self.dlg.comboBox.addItem(i) 
    
answered by 07.09.2018 в 23:11