Hi Friends,

I am using the QTreeView class and the class model QStandardItemModel. I want to popluate the QTreeView with the results of the SQL query.

I am trying something like this only shows one more record:

Qt Code:
  1. SqlQuery queryVtr;
  2. queryVtr.exec("SELECT....");
  3.  
  4. QStandardItemModel *model = new QStandardItemModel(0, 3, this);
  5.  
  6. model->setHeaderData(0, Qt::Horizontal, QObject::tr("Viaturas"));
  7. model->setHeaderData(1, Qt::Horizontal, QObject::tr("Equipamentos"));
  8. model->setHeaderData(2, Qt::Horizontal, QObject::tr("Status"));
  9.  
  10. while (queryVtr.next())
  11. {
  12. QStringList setVtrModel = queryVtr.value(0).toStringList();
  13. treeView->setModel(model);
  14. }
To copy to clipboard, switch view to plain text mode 

Is there an quick way to do this?

edm