ookrin schrieb:
I've been searching around the internet for an example of how to add a
list of items to the qTableWidget for the last few hours with little
success.
I have a list orders [[34,940,30,50,67], [50,56,35,30,57]] as my
example here
I built the qTableWidget in designer, so it already has the header
columns filled out.
Date | time | Number | Price | Buyer
ui.tb1_tblOrders.setRowCount(len(orders))
gives me the correct number of rows I want, but how do I fill the
rows?
I've been trying
while(len(orders)> i):
ui.tb1_tblOrders.setCurrentCell(i,0,orders[i][1])
i+=1
which to me, says go add in the first column row with the first order,
and it makes sense to me
It just says "Error: argument 3 of QTableWidget.setCurrenCell() has
invalid type, I know it's the orders, but I can't figure out what the
proper way of giving it what it wants is.
I don't find setCurrentCell in the docs for QTableWidget - only for Q3Table.
http://doc.trolltech.com/4.0/q3table.html#setCurrentCell
However, that call isn't about setting the value of a cell, instead it's
about giving a cell the focus.
Use setItem instead.
And don't use the wicked while-loop for generating indices - this is
done in python using the enumerate-function:
for i, order in enumerate(orders):
...
Diez
--
http://mail.python.org/mailman/listinfo/python-list