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,
Qt Code:
  1. QSqlQuery sqpre("select Channel_Name,TagId,ChannelIndexPosi from tempchnames");
  2. if(sqpre.exec())
  3. {
  4. if (sqpre.first())
  5. {
  6. do
  7. {
  8. temperaturechnames.push_back(sqpre.value(0).toString());
  9. temptagidnames.push_back(sqpre.value(1).toString());
  10. indexCount.push_back(sqpre.value(2).toString());
  11. } while(sqpre.next());
  12. }
  13. }
  14.  
  15. model1 = new QStandardItemModel();
  16.  
  17. model2 = new QStandardItemModel();
  18.  
  19. for(int i=0;i< temptagidnames.count(); i++)
  20. {
  21. QStandardItem *item = new QStandardItem(temptagidnames.at(i));
  22. model1->setItem(i, 0, item);
  23. }
  24.  
  25. for(int j=0;j< temperaturechnames.count(); j++)
  26. {
  27. QStandardItem *item2 = new QStandardItem(temperaturechnames.at(j));
  28. model1->setItem(j, 1, item2);
  29.  
  30. }
To copy to clipboard, switch view to plain text mode 


Thank you