Sounds like typical constipation. My guess is that she has not pooped much, if at all, in the last few days. The poop tends to bind up in the colon due to lack of water and lack of fiber, which is why it's so hard. The tremendous pressure builds up and then is relieved when the poop comes out, and either that reduction or some kind of back-up in her small intestine and even stomach (due to the temporary blockage) made her nauseated. There's also something called a vaso-vagal response, which is when the vagus nerve is stimulated (which can occur from a variety of things, but bearing down hard during a bowel movement is one of them). That can cause lightheadedness and even fainting, so sometimes that bit of disequilibrium can cause a wave of nausea. And of course, during constipation, bacteria and toxins build up instead of being eliminated in a timely manner. I doubt it's a virus, although if she's got a touch of something, it could have helped to move everything through. If this is followed by a bit of diarrhea, that would be pretty normal.
I don't think there's a cause for concern now that she has pooped - but the cause of it is of greater concern. Some kids kind of hold everything in for a while - younger kids sometimes don't like to part with their poop or are afraid of the toilet, but kids your daughter's age are more likely to not want to spend the time in the bathroom because it takes away from their activities. So I think your focus should be on increasing her water and fiber (most fruits, whole grain breads, brown rice and so on), and decreasing foods that bind her up (e.g. cheese, bananas). I think she'll stabilize quickly.