[Qt-interest] update an existing item in QTreeWidget without user intervension
André Somers
andre at familiesomers.nl
Sat Apr 17 17:35:16 CEST 2010
You could simply keep track of the items yourself in your own, more
efficient data structures if you need. For instance, you can keep a
QHash<QString, QTreeWidgetItem*> to get quick access to the appropriate
items in your display tree. You just have to construct an appropriate
string as key. Probably the combination of cluster and machine name would
do, in your case.
André
Van: qt-interest-bounces at trolltech.com
[mailto:qt-interest-bounces at trolltech.com] Namens Sarvesh Saran
Verzonden: zaterdag 17 april 2010 16:28
Aan: qt-interest at trolltech.com
Onderwerp: [Qt-interest] update an existing item in QTreeWidget without user
intervension
Hi,
I have a QTreeWidget containing hundreds of rows. The items corresponding to
each row are updated by receiving and parsing data from an external
process..
For example, the columns in my tree widget are:
Name of machine Available-memory(GB) load-average
This is how my tree widget looks after I have receive the initial data (data
is read through a socket, and is a string of format cluster1 machine1 1.2
5.0)
Cluster 1
Machine1 1.2 5.0
Machine2 4.8 3.1
.
..
Machine500 2.0 0.1
Cluster 2
Machine501 1.1 8
..
Machine1000 1.2 0.1
Later on, I get the following data update cluster 1 Machine1 1.2 9.0 .This
warrants an update of the tree widget.
I have to first check if an item containing the name Machine1 in first
column exists. If yes, update it. If no, create a new child using cluster 1
as parent.
Im not sure how to search for an item based on a data ( a name in this
case)? I am also concerned about the time complexity of searching through
all child items (there could be thousands).
Thanks,
Sarvesh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100417/65bc9849/attachment.html
More information about the Qt-interest-old
mailing list