![]() Registered Member ![]()
|
Hi, I want to make a Simple Tree View using QTreeWidget in the format
getting the data from a file using the following format( the ip address is an optional parameter):
I have found out that I can use the QTreeWidget using the following pattern:
Now I need help with two things. 1st, how can I populate the QTreeWidget without using variable names as I don't know before hand how many channels and devices associated with it are there. 2nd, I wanted to first do a list of channels and a list of lists of devices so I wrote the following code:
The problem with it is that when I append the list 'devices' to 'equipos' it appends a reference to it and after I modify it it updates it for the 1st instance. So how should I do the list of lists to prevent that from happeing? Or should I use a different way of storing the data? Thanks for your time, Hope you can help me out.
PuercoPop, proud to be a member of KDE forums since 2008-Oct.
|
![]() Administrator ![]()
|
I would recommend looking at QMap and QList for storing your data. I would store it as follows:
QList< Channel > QMap< Channel, Device > QList< QTreeWidgetItem > Then I would iterate over the channel list, and call values( Channel ) on the QMap to get the list of devices in that channel. I would then create the QTreeWidgetItem and append it to a generic list to store them. For retrieving the list of Devices, just call values() on the QMap.
KDE Sysadmin
[img]content/bcooksley_sig.png[/img] |
Registered users: Bing [Bot], daret, Google [Bot], sandyvee, Sogou [Bot]