[Qt-interest] QTreeWidgetItemIterator weird behaviour
Malyushytsky, Alex
alex at wai.com
Tue Oct 20 02:07:56 CEST 2009
As I understand it QTreeWidgetItemIterator when constructed with
QTreeWidgetItemIterator::QTreeWidgetItemIterator(QTreeWidget *widget, IteratorFlags flags)
should visit items starting from the first child. Which children are visited is defined by the flag.
Default flag is to visit All children.
The problem is mostly likely created by refreshInfo which changes the tree.
Remove call to the refreshInfo and test that iterator visits all items.
Changes that refreshInfo introduces are probably lead to sorting.
You may try to disable sorting before obtaining iterator
and re - enable it after you stopped using it.
I am not an expert in PyQt, never used it, so I will use c++ which you might modify to PyQt:
tree->setSortingEnabled( false ); // disable sorting
iterator = QTreeWidgetItemIterator(self.tree)
while iterator.value():
print str(iterator.value().text(self.columns["name"]))
if len(str(iterator.value().text(self.columns["path"]))) > 0 and len(str(iterator.value().text(self.columns['owner']))) >0:
print str(iterator.value().text(self.columns["name"]))
user = str(iterator.value().text(self.columns['owner']))
self.refreshInfo(iterator.value())
self.tree.setSortingEnabled( true ); // re-enable sorting
-----Original Message-----
From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of NARCISO, Rui
Sent: Monday, October 19, 2009 2:51 AM
To: Qt Interest (E-mail)
Subject: [Qt-interest] QTreeWidgetItemIterator weird behaviour
Hi all
Is a QTreeWidgetItemIterator supposed to go trhough the items on a QTreeWidget by any specific order or is it completely random?
I ask this because the first value given by my iterator is not the first one on the list and after going through all the items it fails to give me the very first one !!!!
My code (sorry, it's PyQt but you should be able to read it)
iterator = QTreeWidgetItemIterator(self.tree)
while iterator.value():
print str(iterator.value().text(self.columns["name"]))
if len(str(iterator.value().text(self.columns["path"]))) > 0 and len(str(iterator.value().text(self.columns['owner']))) >0:
print str(iterator.value().text(self.columns["name"]))
user = str(iterator.value().text(self.columns['owner']))
self.refreshInfo(iterator.value())
and
def refreshInfo(self, calculation):
iterator = QTreeWidgetItemIterator(self.tree)
while iterator.value():
if calculation == iterator.value():
iterator.value().setText(self.columns["status"], "...")
from my architecture I need to do these steps as they are in these different functions.
Any advice?
Rui
The information in this e-mail is confidential. The contents may not be disclosed or used by anyone other than the addressee. Access to this e-mail by anyone else is unauthorised.
If you are not the intended recipient, please notify Airbus immediately and delete this e-mail.
Airbus cannot accept any responsibility for the accuracy or completeness of this e-mail as it has been sent over public networks. If you have any concerns over the content of this message or its Accuracy or Integrity, please contact Airbus immediately.
All outgoing e-mails from Airbus are checked using regularly updated virus scanning software but you should take whatever measures you deem to be appropriate to ensure that this message and any attachments are virus free.
_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest
---------------------------------------------------------------------------------------------------
Weidlinger Associates, Inc. made the following annotations.
"This message and any attachments are solely for the intended recipient and may contain confidential or privileged information. If you are not the intended recipient, any disclosure, copying, use, or distribution of the information included in this message and any attachments is prohibited. If you have received this communication in error, please notify us by reply e-mail and immediately and permanently delete this message and any attachments. Thank you."
"Please consider our environment before printing this email."
More information about the Qt-interest-old
mailing list