I load the data into qtableview using a looping that makes the select every 2 seconds. It happens that the screen is locked while the select runs and the data is loaded in the view, each select brings the updated data, but I can't click on the radiobuttons that are locked. I don't know how to implement a way to update the view using dataChanged.emit(), maybe I don't even need to run the select so many times, I looked for some information in English but I couldn't understand a way that I can implement. What I want is that it doesn't lock so that I, through the visualization of the view data (server available), can mark the radiobuttons to update the servers.
https://i.stack.imgur.com/pfikz.png
Model class code:
class TableModel(QAbstractTableModel):
def __init__(self, data):
super().__init__()
self._data = data
def data(self, index, role):
if role == Qt.TextAlignmentRole:
value = self._data[index.row()][index.column()]
if isinstance(value, int) or isinstance(value, float):
return Qt.AlignHCenter
if role == Qt.DisplayRole:
return self._data[index.row()][index.column()]
def rowCount(self, index):
return len(self._data)
def columnCount(self, index):
return len(self._data[0])
main class code:
class Ui_Form(object):
def setupUi(self, Form):
self.pushButton_query.clicked.connect(self.executa_query)
def executa_query(self):
flag = 0
while flag <= execucao:
self.select_dados()
time.sleep(segundos)
flag += 1
if flag == execucao:
self.status_execucao = True
def select_dados(self):
dados = []
sql = """
SELECT * FROM(
SELECT (SELECT COUNT(1)
FROM GUIA_ITEM G
WHERE G.GUIA_COD_ID = ID_GUIA),
S.*
FROM SAPIA_LOG S
WHERE DATA > TRUNC(SYSDATE) - 1
ORDER BY 2 DESC)
WHERE ROWNUM <= 20
"""
self.cur.execute(sql)
for x in self.cur:
dados.append([int(x[0]),int(x[2]),int(x[2]),x[3].strftime("%d/%m/%Y %H:%M:%S"),x[4],x[5],x[6],x[7]])
self.model = TableModel(dados)
self.tableView.setModel(self.model)
self.tableView.resizeColumnsToContents()
self.tableView.resizeRowsToContents()
QApplication.processEvents()