Problem displaying items in a qtablewidget

Asked

Viewed 26 times

0

Only the first two rows of the table are filled, but the table row numbers are filled as the result of the query and in the print displays all items normally,.

def escreveArquivo(self):
    con = MySQLdb.connect(host="localhost", user="root", passwd="pswd", db="cliente")
    cursor = con.cursor()
    cursor.execute('select * from cliente;')
    rs = cursor.fetchall()
    result = self.ui.tableWidget
    result.setRowCount(len(rs))
    result.setColumnCount(5)

    row = 0

    for i in rs:
        result.setItem(row, 0, QtWidgets.QTableWidgetItem(str(i[1])))
        result.setItem(row, 1, QtWidgets.QTableWidgetItem(str(i[2])))
        result.setItem(row, 2, QtWidgets.QTableWidgetItem(str(i[3])))
        result.setItem(row, 3, QtWidgets.QTableWidgetItem(str(i[4])))
        result.setItem(row, 4, QtWidgets.QTableWidgetItem(str(i[5])))
        print(i)
        row =+ 1

1 answer

-1

The problem was solved as follows:

row = row + 1

Browser other questions tagged

You are not signed in. Login or sign up in order to post.