I have a QMainWindow from which I call a Qdialog, the problem is that I use the Qdialog to obtain data, everything works fine when it is used for the first time, but when I use it again, if I do not introduce new values and I simply close it , returns the last returned values. When I call it from MainWindow I do it like this:
self.dialogo=secundal.buscar_cups(resultado,resp)
self.dialogo.exec_()
cod,desc=secundal.buscar_cups(resultado,resp).retorno()
What I have in the secondary file is the following:
import sys
from busqueda_cups import Ui_Dialog
from PyQt4 import QtCore, QtGui
import os
import MySQLdb
id_consulta=''
descripcion=''
class buscar_cups(QtGui.QDialog):
def __init__(self,resultado,num_filas):
QtGui.QWidget.__init__(self)
self.ventana = Ui_Dialog()
self.ventana.setupUi(self)
self.ventana.tableWidget.setRowCount(num_filas)
for i in range(0,len(resultado)):
for j in range(0,2):
self.ventana.tableWidget.setItem(i,j,QtGui.QTableWidgetItem(str(resultado[i][j])))
self.connect(self.ventana.tableWidget,QtCore.SIGNAL('cellDoubleClicked (int,int)'),self.seleccion)
def seleccion(self):
global id_consulta,descripcion
id_consulta=''
descripcion=''
cod,desc=self.ventana.tableWidget.selectedItems()
id_consulta=cod.text()
descripcion=desc.text()
self.close()
def retorno(self):
return id_consulta,descripcion