nagabathula
20th April 2011, 07:41
Hello i have a problem i looked a lot but did not find a exact solution. I have a
QStandardItemModel to which i am adding data which is present in the QVectors which is retrieved from the data base and i set this data Model into the tableView.
This is how i am displaying the data from a data base to QTableView
QStandardItemModel *model1 ;
model1 = new QStandardItemModel();
for(int i=0;i< temptagidnames.count(); i++)
{
QStandardItem *item = new QStandardItem(temptagidnames.at(i));
model1->setItem(i, 0, item);
}
model1->setHeaderData(0, Qt::Horizontal, tr("TAG ID"));
model1->setHeaderData(1, Qt::Horizontal, tr("Description"));
tableView->setModel(model1);
tableView->setAlternatingRowColors(true);
tableView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
I wrote the below code to update the changes made in the QTableView into the sqlite db.
QStandardItemModel *model1 ;
model1 = new QStandardItemModel();
QSqlTableModel *model1;
model1 = new QSqlTableModel;
model1->setTable("tempchnames");
model1->setEditStrategy(QSqlTableModel::OnFieldChange);
tableView->setColumnHidden(0, true);
for(int i=0;i< temptagidnames.count(); i++)
{
QStandardItem *item = new QStandardItem(temptagidnames.at(i));
model1->setItem(i, 0, item);
}
model1->setHeaderData(0, Qt::Horizontal, tr("TAG ID"));
model1->setHeaderData(1, Qt::Horizontal, tr("Description"));
tableView->setModel(model1);
tableView->setAlternatingRowColors(true);
tableView->setSizePolicy(QSizePolicy::Expanding,
But i get errors like, I am not able to know how i can link QStandardItemModel Model and QSqlTableModel so that the changes i make in the QTableView are reflected in the data base immediately.
error C2371: 'model1' : redefinition; different basic types
error C2039: 'setTable' : is not a member of 'QStandardItemModel'
i am stuck with this problem past 2 days,.
Thank you
QStandardItemModel to which i am adding data which is present in the QVectors which is retrieved from the data base and i set this data Model into the tableView.
This is how i am displaying the data from a data base to QTableView
QStandardItemModel *model1 ;
model1 = new QStandardItemModel();
for(int i=0;i< temptagidnames.count(); i++)
{
QStandardItem *item = new QStandardItem(temptagidnames.at(i));
model1->setItem(i, 0, item);
}
model1->setHeaderData(0, Qt::Horizontal, tr("TAG ID"));
model1->setHeaderData(1, Qt::Horizontal, tr("Description"));
tableView->setModel(model1);
tableView->setAlternatingRowColors(true);
tableView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
I wrote the below code to update the changes made in the QTableView into the sqlite db.
QStandardItemModel *model1 ;
model1 = new QStandardItemModel();
QSqlTableModel *model1;
model1 = new QSqlTableModel;
model1->setTable("tempchnames");
model1->setEditStrategy(QSqlTableModel::OnFieldChange);
tableView->setColumnHidden(0, true);
for(int i=0;i< temptagidnames.count(); i++)
{
QStandardItem *item = new QStandardItem(temptagidnames.at(i));
model1->setItem(i, 0, item);
}
model1->setHeaderData(0, Qt::Horizontal, tr("TAG ID"));
model1->setHeaderData(1, Qt::Horizontal, tr("Description"));
tableView->setModel(model1);
tableView->setAlternatingRowColors(true);
tableView->setSizePolicy(QSizePolicy::Expanding,
But i get errors like, I am not able to know how i can link QStandardItemModel Model and QSqlTableModel so that the changes i make in the QTableView are reflected in the data base immediately.
error C2371: 'model1' : redefinition; different basic types
error C2039: 'setTable' : is not a member of 'QStandardItemModel'
i am stuck with this problem past 2 days,.
Thank you