Oh the poor love. That's so distressing - for both of you.
When it looks like she's likely to poo, or she's straining, try rubbing some butter or margarine into her anus. It sounds weird, I knowm, but it does ease the way, and the gentle pressure of your finger on her anus may make the passing of thepoo less painful. The rectum doesn't come straight down to the anus, there is a sort of kink just before it reaches the anus, so that a very hard and large poo presses on the flesh just behind the anus. If you can press on it gently to support it, it also seems to make the poo easier and less painful to pass. I have done this with my ds when he was a baby. He was lying on his back, though. I don't know how you'd do this if your dd is sitting on the loo.
Another thing that might help is to put a step at the loo, so that she can rest her feet on it and not have her legs dangling.
Long term (and I speak purely as a parent, and not a medical person) I think she needs some sort of medical intervention to get her pooing gently in order to ease the psychological problem. I presume you mean the problem is that she is afraid of pooing, hold it in, and then of course her fear is validated because it hurts to poo. I know drs don't like to prescribe strong medication for constipation, but she needs a break! A chance to heal physically and emotionally, and to relearn good habits.
What diet have you tried? More liquids and roughage? Has she been checked for intolerances or allergies?