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:
Qt Code:
  1. QStringList jobslist = jobs();
  2. m_jobsmodel = new QStandardItemModel;
  3.  
  4. QStringList headerLabels;
  5. headerLabels << "Date" << "UUID" << "Assigned" << "Due Date" << "Status";
  6. m_jobsmodel->setHorizontalHeaderLabels(headerLabels);
  7.  
  8. foreach(const QString& job, jobslist) {
  9. QList <QStandardItem *> jobItem;
  10. jobItem << new QStandardItem(QIcon(":/png/64x64/accept.png"), jobTitle(job));
  11.  
  12. QStringList tasks = tasksByJob(job);
  13. foreach(const QString& task, tasks) {
  14. QList<QStandardItem*> items;
  15. items << new QStandardItem(QIcon(":/png/64x64/remove.png"), taskTitle(task));
  16. items << new QStandardItem(task);
  17. items << new QStandardItem(taskAssignee(task));
  18. items << new QStandardItem(taskDue(task));
  19. items << new QStandardItem(taskStatus(task));
  20.  
  21. jobItem.at(0)->appendRow(items); // append child items to top-level item
  22. }
  23. m_jobsmodel->appendRow(jobItem);
  24. }
To copy to clipboard, switch view to plain text mode 

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.