PDA

View Full Version : model View programming problem



mismael85
2nd April 2008, 15:53
hi,
i have a problem in a program that use model view.
i have QTreeView object that display titles of a book, these titles are over than 5000
title and they are stored in a SQLITE database.

i tried two solution :
1- i inhreted QAbstractItemModel but i get some problems becuase as i understanded from the documentation that i should store the data items in my own class.
2- i tried to to use QStandardItemModel but i noteced that i should store the titles in a
separated QList of of QStandardItem.

now i want to use the database directly without any model becuase this takes alot of memory. and i want this job to be fast as possible because i may have titles more than 10,000 .
i am thinking :
can i use just QTreeWidget to access the database via a QSqlQuery class?
if you have any other solutions please help me?

wysota
2nd April 2008, 17:32
Have you seen QSqlTableModel and QSqlQueryModel?

mismael85
2nd April 2008, 22:28
yes, i know these two classes .
but as i know that they are not working with trees.
note :
i have a table in my database that has the following schem :
+id (1, 2, 3,4, ...)
|
+title (title1, title1-1, title2, ....)
|
+lvl (1, 2,1,....)
|
+sub (0,0,0,...)
i want to list the titles in the tree and put each title in it's appropriate level according to lvl field.

wysota
2nd April 2008, 22:44
They are not working with trees but you can apply a proxy on a flat model to make it hierarchical.