My DS is a sufferer. You need to find a sympathetic pharmacist who will let you buy glycerine suppositories. You pop one up her bum and it melts and softens the stopper of poo that is usually too hard to push out.
If you want a medicine, you can give Califig to a two year old, it's very effective. Prunes, pineapple or kiwi fruit always work for my dd too. Best thing though is prevention - lots of fruit and lots of water to help stop it happening again.
Plenty of fibre in the form of fruit and veg. Foods that contain fibre like brown bread, Weetabix etc can often make the problem worse as you need to drink a lot of fluids as that sort of fibre absorbs a lot of water, so stools can become hard and impacted.
Raisins, apricots (dried fruit in general) helps, as does fruit juice rather than squashe for fluids.
The suppositories do help when you have a problem, not to be used all the time but when there is a poor there which is stuck.
I agree with twiglett, lots and lots of fluids. I was talking to my HV about this recently and she said that lots of people make the mistake of giving a constipated baby/child foods high in fibre which bung them up even more. Increase her fluid intake and that should do the trick.