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:
SqlQuery queryVtr;
queryVtr.exec("SELECT....");
model
->setHeaderData
(0, Qt
::Horizontal,
QObject::tr("Viaturas"));
model
->setHeaderData
(1, Qt
::Horizontal,
QObject::tr("Equipamentos"));
model
->setHeaderData
(2, Qt
::Horizontal,
QObject::tr("Status"));
while (queryVtr.next())
{
QStringList setVtrModel
= queryVtr.
value(0).
toStringList();
treeView->setModel(model);
}
SqlQuery queryVtr;
queryVtr.exec("SELECT....");
QStandardItemModel *model = new QStandardItemModel(0, 3, this);
model->setHeaderData(0, Qt::Horizontal, QObject::tr("Viaturas"));
model->setHeaderData(1, Qt::Horizontal, QObject::tr("Equipamentos"));
model->setHeaderData(2, Qt::Horizontal, QObject::tr("Status"));
while (queryVtr.next())
{
QStringList setVtrModel = queryVtr.value(0).toStringList();
treeView->setModel(model);
}
To copy to clipboard, switch view to plain text mode
Is there an quick way to do this?
edm
Bookmarks