Hi,

I am getting an infinite loop while trying to modify an item on the tableWidget and subsequently in the corresponding file as well and display the same onto the screen using the below signal and slot mechanism. I have also tried to use other signals to trigger the same but it results in the same loop.
I have tried triggering the signal from a different function and from the constructor but both result in the same.

connect(ui->tableWidget,SIGNAL(itemChanged(QTableWidgetItem*) ),this,SLOT(onEditView(QTableWidgetItem*)));


The following is the user defined slot.
Qt Code:
  1. void MainWindow::onEditView(QTableWidgetItem* item){
  2. QString changed_t = ui->tableWidget->currentItem()->text();
  3.  
  4. //Obtaining the row and column values for the edited item
  5. int r_id= changed_t->row();
  6. int c_id=changed_t->column();
  7. int line_count=0;
  8.  
  9. //Changing the particular value in the file
  10. QFile file_r("address1.txt");
  11.  
  12. if(!file_r.exists()){
  13. return;
  14. }
  15.  
  16. QString line_app;
  17. QTextStream wstream(&file_r);
  18.  
  19. if(file_r.open(QIODevice::ReadWrite)){
  20.  
  21. while(!file_r.atEnd()){
  22. QStringList line_data;
  23. QString line=file_r.readLine();
  24. line=line.simplified();
  25. line_data=line.split(";",QString::SkipEmptyParts);
  26.  
  27. for(int j=0;j<line_data.size();j++){
  28.  
  29. if((j==c_id)&&(line_count==r_id)){
  30. line_data.replace(j,changed_t);
  31. qDebug()<<"split: "<<line_data;
  32. line.clear();
  33. if(j==line_data.size()-1){
  34. line_app.append(line_data.at(j)+"\n");
  35. }
  36. else{
  37. line_app.append(line_data.at(j)+";");
  38. }
  39. }
  40. ...........
To copy to clipboard, switch view to plain text mode 

Any advice on the above?