我有以下代码(PyQt)
:
searchFrameObject.tableWidget.setRowCount(rowCounter)
searchFrameObject.tableWidget.setColumnCount(5)
for row in range(rowCounter):
for column in range(5):
for result in query:
item = QtGui.QTableWidgetItem(_fromUtf8(result.name))
item.setFlags(item.flags() ^ QtCore.Qt.ItemIsEnabled)
searchFrameObject.tableWidget.setItem(row,column,item)
#item = QtGui.QTableWidgetItem(String(result.bought_price))
#item.setFlags(item.flags() ^ QtCore.Qt.ItemIsEnabled)
#searchFrameObject.tableWidget.setItem(row,column+1,item)
#item = QtGui.QTableWidgetItem(result.bought_date)
#item.setFlags(item.flags() ^ QtCore.Qt.ItemIsEnabled)
#searchFrameObject.tableWidget.setItem(row,column+2,item)
item = QtGui.QTableWidgetItem(result.stock)
item.setFlags(item.flags() ^ QtCore.Qt.ItemIsEnabled)
searchFrameObject.tableWidget.setItem(row,column+3,item)
item = QtGui.QTableWidgetItem(result.minimum_bound)
item.setFlags(item.flags() ^ QtCore.Qt.ItemIsEnabled)
searchFrameObject.tableWidget.setItem(row,column+4,item)
当我在 DB 中搜索时,我print result.name
或print result.stock
,一切正常。但是当我将它们导入时,我只看到添加QtableWidget
了节点。(从 填充的所有节点)result.name
widgets
result.name
我的问题是,我如何用我的字段填充行和列?