rex
5th February 2011, 08:46
Hi freiends i am working on a small project in which i have to display some data in a table with some 4 columns.. I am retrieving the data in the sqlite db and updating the model view. But i wanted to even save the data which is modified while viewing.. i saw void QStandardItemModel::itemChanged ( QStandardItem * item ) but how can i capture the text that i have changed while i viewed it..
QSqlQuery sqpre("select Ch_Name,TagId,Chpos from tpchn");
if(sqpre.exec())
{
if (sqpre.first())
{
do
{
tpch.push_back(sqpre.value(0).toString());
tagid.push_back(sqpre.value(1).toString());
} while(sqpre.next());
}
}
And this part of the code to display the data retrieved from the db to the ModelView..
for(int i=0;i< tagid.count(); i++)
{
QStandardItem *item = new QStandardItem(tagid.at(i));
model->setItem(i, 0, item);
}
for(int j=0;j< tpch.count(); j++)
{
QStandardItem *item2 = new QStandardItem(tpch.at(j));
model->setItem(j, 1, item2);
}
how can i capture the text which is changed here so that i can save it back to the db.. i wanted to update the changes in the text i make in the tableview.
thank you
QSqlQuery sqpre("select Ch_Name,TagId,Chpos from tpchn");
if(sqpre.exec())
{
if (sqpre.first())
{
do
{
tpch.push_back(sqpre.value(0).toString());
tagid.push_back(sqpre.value(1).toString());
} while(sqpre.next());
}
}
And this part of the code to display the data retrieved from the db to the ModelView..
for(int i=0;i< tagid.count(); i++)
{
QStandardItem *item = new QStandardItem(tagid.at(i));
model->setItem(i, 0, item);
}
for(int j=0;j< tpch.count(); j++)
{
QStandardItem *item2 = new QStandardItem(tpch.at(j));
model->setItem(j, 1, item2);
}
how can i capture the text which is changed here so that i can save it back to the db.. i wanted to update the changes in the text i make in the tableview.
thank you