Sorry, I do not understand your code at all.
I am pretty sure you are not saving anything into the file. Check the generated file and make sure that the data you expect is there.
QVariant::toString() is not meant to serialize data but to convert simple data into strings when possible. It will most likely fail with complex data found in a typical QVariantMap and return a empty string.
What type is "contacts"? I guess a QVariantMap or something... You are generating a key "filename" there and put some data into that (not into any file).
You do not read any data from the file in the open_button_clicked method. So even if you had managed to put data into a file you will not be able to restore it.
No idea what you want to do with the iterator... There is no loop, so you are not iterating over the contacts data. You find the position of the element you care about, then move to the next element. If you are then at the end of the data structure you move to the first element... yeap, that works, but only if there is exactly one element in your structure.
You use the data found in that structure to call into javascript.
I would suggest doing the following:
remove "contacts". I do not see why that is needed.
Print in Javascript what the save function returns. Check that it is what you expect. Fix the Javascript till it does return what you want.
Print content and data variables in save_button_clicked. Make sure it is what you expect. Fix the code till it does.
Open a file, write a static string into it, close it again. Check that the file is really created and contains the string you wrote into it.
Replace the static string with the data. Check that the file is still created and contains the expected data. Fix the code till it does.
Only when all this works I would continue with the open_button_clicked method, using a similar approach. No, I will not provide code: Coming up with this code is your job, not mine:-)
Best Regards,
Tobias