Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #53863

Re: Logical error in filling QTableWidget and filling all of nodes

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!eweka.nl!lightspeed.eweka.nl!194.109.133.83.MISMATCH!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python@mrabarnett.plus.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'subject:error': 0.03; '(all': 0.07; 'column': 0.07; 'rows': 0.09; 'skip:/ 10': 0.09; 'columns': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'iterating': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'nodes': 0.16; 'skip:q 30': 0.16; 'skip:q 50': 0.16; 'widgets.': 0.16; 'skip:# 20': 0.16; 'wrote:': 0.18; 'all,': 0.19; 'import': 0.22; 'print': 0.22; 'header:User-Agent:1': 0.23; 'question': 0.24; 'header:In- Reply-To:1': 0.27; 'code': 0.31; 'node': 0.31; 'ok.': 0.31; 'skip:q 20': 0.31; 'subject:all': 0.32; 'but': 0.35; 'filled': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; "you're": 0.61; 'dear': 0.65; 'header:Reply-To:1': 0.67; 'reply-to:no real name:2**0': 0.71; 'reply- to:addr:python.org': 0.84; 'subject:Logical': 0.84
X-CM-Score 0.00
X-CNFS-Analysis v=2.1 cv=bL0vfpOZ c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=0kkAYlmtguIA:10 a=MHpDIr_R0AIA:10 a=ihvODaAuJD4A:10 a=OUOv7kDek9cA:10 a=8nJEP1OIZ-IA:10 a=EBOSESyhAAAA:8 a=8AHkEIZyAAAA:8 a=oNRBIzYiESsA:10 a=YvxmYyh50RocuO0lJ_gA:9 a=wPNLvfGTeEIA:10
X-AUTH mrabarnett:2500
Date Mon, 09 Sep 2013 12:24:04 +0100
From MRAB <python@mrabarnett.plus.com>
User-Agent Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130801 Thunderbird/17.0.8
MIME-Version 1.0
To python-list@python.org
Subject Re: Logical error in filling QTableWidget and filling all of nodes
References <1378703716.6005.47.camel@debian>
In-Reply-To <1378703716.6005.47.camel@debian>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
Reply-To python-list@python.org
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.172.1378725850.5461.python-list@python.org> (permalink)
Lines 59
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1378725850 news.xs4all.nl 15901 [2001:888:2000:d::a6]:59553
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:53863

Show key headers only | View raw


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 comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Logical error in filling QTableWidget and filling all of nodes MRAB <python@mrabarnett.plus.com> - 2013-09-09 12:24 +0100

csiph-web