Hello every one, i am working on a project where i display some data from sqlite database in a QTableView widget.. I am having a small problem, wanted to know how i can make QTableView editable and save the changes i make on the QTableView into the sqlite data base.. right now i am doing this i retrieve the data from Sqlite db and display it in the QTableView but i am not able to figure out how i can make it editable and save those changes into the sqilte db..
This is what i am doing to display the data from the sqlite db into QTableView now,
QSqlQuery sqpre
("select Channel_Name,TagId,ChannelIndexPosi from tempchnames");
if(sqpre.exec())
{
if (sqpre.first())
{
do
{
temperaturechnames.push_back(sqpre.value(0).toString());
temptagidnames.push_back(sqpre.value(1).toString());
indexCount.push_back(sqpre.value(2).toString());
} while(sqpre.next());
}
}
for(int i=0;i< temptagidnames.count(); i++)
{
model1->setItem(i, 0, item);
}
for(int j=0;j< temperaturechnames.count(); j++)
{
model1->setItem(j, 1, item2);
}
QSqlQuery sqpre("select Channel_Name,TagId,ChannelIndexPosi from tempchnames");
if(sqpre.exec())
{
if (sqpre.first())
{
do
{
temperaturechnames.push_back(sqpre.value(0).toString());
temptagidnames.push_back(sqpre.value(1).toString());
indexCount.push_back(sqpre.value(2).toString());
} while(sqpre.next());
}
}
QStandardItemModel *model1 ;
model1 = new QStandardItemModel();
QStandardItemModel *model2;
model2 = new QStandardItemModel();
for(int i=0;i< temptagidnames.count(); i++)
{
QStandardItem *item = new QStandardItem(temptagidnames.at(i));
model1->setItem(i, 0, item);
}
for(int j=0;j< temperaturechnames.count(); j++)
{
QStandardItem *item2 = new QStandardItem(temperaturechnames.at(j));
model1->setItem(j, 1, item2);
}
To copy to clipboard, switch view to plain text mode
Thank you
Bookmarks