Sql Tree Model/View
-
Hello all,
I have a SQL table (SQLite) with the following structure:
@CREATE TABLE filters (id INTEGER PRIMARY KEY AUTOINCREMENT, name VARCHAR(30), key VARCHAR(30), parent INTEGER, FOREIGN KEY(parent) REFERENCES filters(id))@There is a column "parent" which indicates the parent of each item. I would like to load it in a QTreeView. I already get all the data from a QSqlTableModel but the table is flat, meaning with no parent-child relationship. How can I make this happen?
Thanks in advance!
-
Hi,
For that you would need a proxy that will create the proper hierarchy based on your table model content. Or maybe make your own model that will query the database and build the structure
Hope it helps
-
OK, thank you. I will check both solutions.