Actually just had one like this myself. It
looks like what happens is that the pitch count from that at-bat is wiped (or at the very least it doesn't factor in anything), and generates a new one when the new pitcher enters the game. Basically, the count from the pitcher getting subbed out never happened - that's what it looks like to me.
I'd imagine the little details like this are why you can't turn QC on/off in the middle of the game.