[Qt-interest] QSqlTableModel to QTreeView possible??

Davor J. DavorJ at live.com
Mon Nov 30 20:29:10 CET 2009


I am trying to convert a table into a tree, hereby making use of the 
aforementioned model and view. I can create/order the table anyhow I want. 
Currently, every row in the table represents a path of the tree, which means 
that for some row an element in the "column-1" is the parent of the element 
of "column". This would be very simple to implement in the Q3 way, using 
QTreeWidget, but the Q4 model/view programing (in which I am determined to 
make it) is making me pull my hair out.

According to the Qt "model/view programming" documentation, I should 
re-implement index() and parent() in the model (which are hardly implemented 
by the QSqlTableModel), so as to allow the QTreeView to make trees. I have 
tried many things, but non of them seem to work. Whatever I do I get the 
default table-like view from the QTreeView. Is there something I am missing?

So, the question seems simple: What should I return from index() and 
parent() to make this thing work?

Kind regards,
Davor





More information about the Qt-interest-old mailing list