QTreeView & Sql Database.
Is the only way to display a QTreeView to loop through a record set and manually construct a hierarchical model?
So far the only examples I can find for QTreeView are pretty much manually constructed. What if I wanted changes to the data to be displayed in other widgets or written back to the data source?
All I can find are examples like this:
Code:
headerLabels << "Date" << "UUID" << "Assigned" << "Due Date" << "Status";
m_jobsmodel->setHorizontalHeaderLabels(headerLabels);
foreach(const QString& job, jobslist) {
QList <QStandardItem
*> jobItem;
foreach(const QString& task, tasks) {
QList<QStandardItem*> items;
jobItem.at(0)->appendRow(items); // append child items to top-level item
}
m_jobsmodel->appendRow(jobItem);
}
I am aware that data in an sql table is 2D, but surely there is a mechanism to display 2D data in a hierarchical form without having to construct a copy of what is in the database?
Thanks for your advice in advance.
Re: QTreeView & Sql Database.
There are QSqlTableModel , QSqlRelationalTableModel and other related classes. However, they follow more of a master detail concept than a tree like structure.