e.g. If a King died childless but left his wife pregnant would the child (assuming it lived) succeed to the throne, or would the crown pass to his brother for example? Would the child not be left with a better claim?
It would depend on the specific succession law(s) of the kingdom.
The example you asked is exactly what happened in France after the death of King Louis X the Headstrong. He died childless in 1316 however leaving his wife Queen Clemence pregnant.
For the first time in decades the succession from father to son was questioned. They decided to wait for the Queen to give birth, hoping for a boy. Meanwhile Louis' brother Philippe was named regent ( as it would happen in the case of an underage monarch ) of France until the birth of a prince or princess ( if it was a princess, she would not become queen of France as women were not allowed ).
Eventually the 14th of November 1316, the Queen gave birth to a boy named John ( Jean I ). It meant that the succession was secured ( though very weak with only once infant king ) and a regent would rule until the king is old enough.
In that case it did not happen though as the baby king died five days later ( a natural death as an infant ) which earned him the nickname of John the Posthumous and his uncle Philippe inherited the throne as Philippe V.
I can't tell you of other example though but it did happen.
Source : The Kings of France ( les Rois de France ) by Jean-Baptiste Santamaria