[Qt-interest] QSqlQueryModel to QTableView problem

Gillen Daniel gillen.daniel at gmail.com
Tue Feb 2 11:05:14 CET 2010


Hi @all

I am facing some sort of problem here and don't seem to find a solution 
anywhere :(

I have an SQL table containig objects with some sort of path-like id's.
As an example:

'/0', other fields....
'/0/1', ......
'/0/1/test.txt', .......
'/0/2', ....

I want to display these rows in a QTreeView in the following manner:

/
|-- /0
|    |-- /0/1
|         |-- /0/1/test.txt
|-- /0/2

I've set up a QSqlQueryModel that only queries the first column from the 
database and am setting it with setModel() to my QTableView but all 
items are displayed as "root objects" and don't make some sort of tree.

Can anyone give me a hint on how I can manage to get a tree? How does I 
tell QTreeView that there are parents and childrens that are recognized 
by the '/' char in my query results?

Thx in advance.

Dan



More information about the Qt-interest-old mailing list