Preheat oven to 350 degrees F. Sift flour, sugar and salt into a bowl. Rub in the diced butter until the mixture resembles bread crumbs. Combine the mixture with the egg and cream.
Melt the butter in a saute pan, add onions, salt and pepper. Cook onions until soft and golden in color.
Grease a deep 12-inch flan tin, and line with grease-proof paper. Roll out pastry so that it is larger than the flan tin and bake blind for 10 minutes. Trim pastry edges and leave to cool.
Strain the juice from the onion mixture and fill the pastry case. Whisk the eggs and cream together and pour over the onions. Grate the cheese over the top and place in oven for a further 30 minutes or until the egg mixture is set.