The behaviour is (probably) because you can't insert into two tables with a single insert statement. Using this model you can only insert into the table which you set to be the model table ("customers" in your case). That's why you have to reference "city" and not "city_name".

Now we come to the second part -- the Problem(R).

I would try two things:

1.
Qt Code:
  1. rec.setValue("city", "London");
To copy to clipboard, switch view to plain text mode 
2.
Qt Code:
  1. rec.setGenerated("city", true);
To copy to clipboard, switch view to plain text mode 

A third thing to do could be to check what is the type of QVariant associated with "city" field (using rec.field().type()).