how do iterate over QList retrieve the values then display them on a dialog for editing?
here is my function

Qt Code:
  1. void AddressBook::editItem()
  2. {
  3.  
  4. if( !tableWidget->currentItem())
  5. return;
  6. else
  7. QList<QTableWidgetItem*> selected = tableWidget->selectedItems();
  8. for (QList<QTableWidgetItem *>::iterator it=selected.begin();it!=selected.end();it++)
  9. {
  10. QString item[i] = (*it);
  11. }
  12.  
  13. editDialog dlg;
  14. dlg.setId(item[0]);
  15. dlg.setname(item[1]);
  16. dlg.setemail(item[2]);
  17. dlg.setphone(item[3]);
  18. dlg.setgrossSalary(item[4]);
  19.  
  20.  
  21. if( dlg.exec() == QDialog::Accepted )
  22. {
  23. double HRA = dlg.grossSalary().toDouble() * 0.2;
  24. double transport = dlg.grossSalary().toDouble() * 0.1;
  25. double medical = 200.0;
  26.  
  27. item[0] = dlg.id();
  28. item[1] = dlg.name();
  29. item[2] = dlg.email();
  30. item[3] = dlg.phone();
  31. item[4] = dlg.grossSalary();
  32.  
  33. item[5] .setNum( item[4].toDouble() - HRA - transport - medical,'f',2 ); //netsalary
  34.  
  35. item[6].setNum(item[5].toDouble() * 12,'f',4);
  36. ++row;
  37. for(int col = 0; col < 7 ; col++)
  38. {
  39.  
  40. QTableWidgetItem *newItem = new QTableWidgetItem(tr("%1").arg(item[col]));
  41.  
  42. newItem->setTextAlignment(Qt::AlignCenter);
  43.  
  44. tableWidget->setItem(row, col, newItem);
  45. }
  46. }
  47.  
  48. }
To copy to clipboard, switch view to plain text mode 

when i compiled the program i got this error!


Running build steps for project myaddressbook...
Configuration unchanged, skipping QMake step.
Starting: /usr/bin/make debug -w
make: Entering directory `/home/roncriss/development/myaddressbook'
/usr/bin/make -f Makefile.Debug
make[1]: Entering directory `/home/roncriss/development/myaddressbook'
g++ -c -m64 -pipe -g -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++-64 -I. -I/usr/include/QtCore -I/usr/include/QtCore -I/usr/include/QtNetwork -I/usr/include/QtNetwork -I/usr/include/QtGui -I/usr/include/QtGui -I/usr/include -I. -Idebug -I. -o debug/addressbook.o addressbook.cpp
addressbook.cpp: In member function ‘void AddressBook::editItem()’:
addressbook.cpp:115: error: ‘selected’ was not declared in this scope
addressbook.cpp:117: error: variable-sized object ‘item’ may not be initialized
addressbook.cpp:117: warning: unused variable ‘item’
addressbook.cpp:121: error: ‘item’ was not declared in this scope
make[1]: Leaving directory `/home/roncriss/development/myaddressbook'
make: Leaving directory `/home/roncriss/development/myaddressbook'
make[1]: *** [debug/addressbook.o] Error 1
make: *** [debug] Error 2
Exited with code 2.
Error while building project myaddressbook
When executing build step 'Make'