How to potty train a girl?

My 4, almost five-year-old daughter has stopped using the toilet and won’t tell me or anyone when she needs to do a wee. She used to always tell me when she needed the toilet and was using it fine on her own with accidents every now and then but has recently stopped going altogether and has started to pee her pants every time she needs to go. It happens 3 or 4 times a day, she will be just sitting on the lounge or standing in the kitchen or playing with her toys, and she just wee’s herself. I have told her and explained time and time and time again that you don’t wee in your pants, you wee on the toilet, and to tell me when she needs to go. When I ask her why she isn’t doing wee’s on the toilet anymore, she just looks at me with a confused look on her face as if she doesn’t know what she’s done. This is also happening at school, she is going through 3-4 pairs of pants a day at school, and none of the other kids have this problem. I’m so frustrated and don’t know what to do. I’m at my wits end and am so sick of repeating myself and getting nowhere and it’s really embarrassing.