Home > OS >  Print out array in table widget
Print out array in table widget

Time:12-02

How to print out 1d array in table widget? I have array Sum_main(float data) and table table_Sum. Table has 1 col and 5 rows.

I tried this:

item=self.ui.table_Sum(str(Sum_main))
for row in range(5):
    self.ui.table_Sum.setItem(row, 0, self.ui.table_Sum.item(str(Sum_main[row][0])))

But get error: TypeError: 'QTableWidget' object is not callable.

I have textEdit but I call them using self.ui.textEdit. When I changed code to this, my array print out fully in each row with square brackets at start and end([]):

for row in range(5):
    item=QTableWidgetItem(str(Sum_main))
    self.ui.table_Sum.setItem(row, 0, item)

CodePudding user response:

Try this:

for row in range(5): 
    item=QTableWidgetItem(str(Sum_main[row]))           
    self.ui.table_Sum.setItem(row, 0, item) 
  • Related