I have the following code, the result of the cursor returns the correct data, the problem that the comboBox does not show, is the correct way to fill it?
print([str(x[0]) for x in cursorUsuario])
['1', '4', '5', '6', '9']
self.dlg.comboLote.addItems([str(x[0]) for x in cursorUsuario])
Function where I fill the comboBox
def obtenerUsuario(self,doc):
with open(doc, 'r') as searchfile:
for line in searchfile:
if "url=https://test/ows/wfs" in line:
nombreConexion = line.split('\')[1]
nombreUsuario = nombreConexion+"\username"
passwordUsuario = nombreConexion+"\password"
for linea in searchfile:
if nombreUsuario in linea:
usuario = linea.split("=")[1]
usuarioSiena = usuario.rstrip()
sqlLote = ("select lot.idLote from [inf].[Lote] lot \
inner join [dbo].[Usuario] u on lot.idUsuario = u.idUsuario \
where u.userName = '%s'") % \
(usuario)
self.dlg.comboLote.clear()
cursorUsuario = connUsuario.execute(sqlLote)
print([str(x[0]) for x in cursorUsuario])
self.dlg.comboLote.addItems([str(x[0]) for x in cursorUsuario])
I call the function:
def run(self):
self.dlg.comboLote.clear()
self.obtenerUsuario("C:\Users\usuario\AppData\Roaming\QGIS\QGIS3\profiles\default\QGIS\QGIS3.ini")