There are actually two ways of doing this: By pointing the legs to the direction the player is moving, or by pointing them to the direction he's trying to move.
In the first case, if you try to walk sideways and a wall blocks you, your legs won't turn to the side, because you've stopped. In the second case, your legs will keep facing the direction you wanted to go.
Coding the first case in QC is simple, since all you need is the velocity and angles, but coding the second case is harder and may require access to the raw input of the keyboard/mouse/controller.