certqt
27th October 2010, 16:55
I am trying to populate (and later hopefully edit) a QTreeView whose nodes are stored in a SQL table.
The structure is very simple and similar to a document:
Root
|___Text
|___Text
|___Text
So the table is just:
ID: Int
Text: Varchar
ParentID: Int
I have read very many posts with similar questions and understand that the key is to use a QAbstractProxyModel between the QTreeView and the QSqlTableModel, in particular to look at implementing mapFromSource and mapToSource. I have also looked at the Interview demo which I think should be a good reference to link a flat structure to a tree.
Unfortunately being very new to Qt and still learning some of the advanced aspects of C++, I am struggling to fully understand what to do.
I would therefore really appreciate if someone has got some working code that I can try out and learn from - thanks :)
The structure is very simple and similar to a document:
Root
|___Text
|___Text
|___Text
So the table is just:
ID: Int
Text: Varchar
ParentID: Int
I have read very many posts with similar questions and understand that the key is to use a QAbstractProxyModel between the QTreeView and the QSqlTableModel, in particular to look at implementing mapFromSource and mapToSource. I have also looked at the Interview demo which I think should be a good reference to link a flat structure to a tree.
Unfortunately being very new to Qt and still learning some of the advanced aspects of C++, I am struggling to fully understand what to do.
I would therefore really appreciate if someone has got some working code that I can try out and learn from - thanks :)