To replace the edited value of the QLineEdit in the xml, I was thinking of using the position in the grid of the widget (basically the row number) and associating it with the position of the tag in the xml file. What do you think?
I think it would be better to add a new field to the XML element - a "key" or "id" that you can use as the unique property the you can assign to the QLineEdit. When the edited value changes, you get the property from the widget, find the same key or id in your XML, and use that to change the value.

Using the location of the widget in the grid to find it in the XML is fragile - if you add a new widget or change the order of the widgets in the XML, then the mapping between the grid and the XML is no longer correct. Adding a "key" that uniquely maps between widget and XML makes your layout independent of the number and placement of the widgets in the XML.

To make it easy, you could use a QMap< QString, QDomElement * > data structure to give you a quick way to look up the XML element that gets changed whenever the QLineEdit with that key (the QString):

Qt Code:
  1. void MyDialog::onEditingFinished()
  2. {
  3. QLineEdit * pEdit = qobject_cast< QLineEdit * >( sender() );
  4. if ( pEdit )
  5. {
  6. QString text = pEdit->text();
  7. QString key = pEdit->property( "key" ).toString();
  8.  
  9. // QMap< QString, QDomElement * > mKeyMap is a member of MyDialog
  10. QDomElement * pXML = mKeyMap[ key ];
  11. pXML->setAttribute( "myAttr", text );
  12. }
  13. }
To copy to clipboard, switch view to plain text mode 

You build the QMap when you read the XML to create the GUI. And of course you would add error checking to the code above to make sure that the "key" exists in the map, and that the map lookup has returned a non-null pointer.