Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #53863 > unrolled thread
| Started by | MRAB <python@mrabarnett.plus.com> |
|---|---|
| First post | 2013-09-09 12:24 +0100 |
| Last post | 2013-09-09 12:24 +0100 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Logical error in filling QTableWidget and filling all of nodes MRAB <python@mrabarnett.plus.com> - 2013-09-09 12:24 +0100
| From | MRAB <python@mrabarnett.plus.com> |
|---|---|
| Date | 2013-09-09 12:24 +0100 |
| Subject | Re: Logical error in filling QTableWidget and filling all of nodes |
| Message-ID | <mailman.172.1378725850.5461.python-list@python.org> |
On 09/09/2013 06:15, Mohsen Pahlevanzadeh wrote:
> Dear All,
>
> I have the following code (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)
> ////////////////
>
> When i search in DB, i print result.name or print result.stock ,
> everything is OK. But when i import them into QtableWidget i see just
> node result.name addeed to widgets. (all of nodes filled from
> result.name)
>
> My Question is , How i fill rows and columns with my fields?
>
I don't understand why you're iterating across the columns:
for column in range(5):
and also setting multiple columns on each iteration:
searchFrameObject.tableWidget.setItem(row,column,item)
...
searchFrameObject.tableWidget.setItem(row,column+3,item)
...
searchFrameObject.tableWidget.setItem(row,column+4,item)
That means that: when 'column' is 0 you're setting column 0 to
result.name, column 3 to result.stock, and column 4 to
result.minimum_bound; when 'column' is 1 you're setting column 1 to
result.name, column 4 to result.stock, and column 5 to
result.minimum_bound; etc.
Back to top | Article view | comp.lang.python
csiph-web