[PyQt] treeview model/view or item-based?

Ulrich ulrich.mierendorff at gmx.net
Mon May 5 20:59:19 BST 2008


Hi,
I have tree-structured data, something like a filesystem where you have 
folders and files.
FolderA
+-----FolderA1
+-----FolderA2
------+------FileA2.1
+-----FolderA3
FolderB
FolderC
I think you know what I mean ;-)
The tree has 3 to 4 levels. Let's say the first level contains 30 items, 
the second level 2000 and the third contains 7000 "folders". The last 
level contains 50,000 items.

I thought it would be a good idea (?) to store the data in a database 
like SQLite, because this is provided by PyQt and it is searchable. I 
would store the 50,000 items in one table like this:
FOLDER_NAME_LVL1,   FOLDER_NAME_LVL2,   .., ITEM_NAME other data
...
with such a table it would be possible to build the tree:
FOLDER_NAME_LVL1
+-----FOLDER_NAME_LVL2
--------+------ITEM_NAME
etc. etc.


So where is my Problem? Such a tree should be displayed with a 
QT-Treeview. There are two different ways: Item-based or model-view 
based. A model-view based approach could become difficult, because the 
model has to build tree-nodes from a 2-Dimensional Table. Does something 
like this already exist in PyQt? On the other hand, I have to create all 
the 50,000 nodes at once if I use the Item-based approach.

Which one would you use? Or is there another (easy) way to handle such 
datasets.

Regards,
Ulrich




More information about the PyQt mailing list