The conventional dynamic-based motion control for quadruped robots is sensitive to terrain errors and has difficulty in adapting to rough terrains. For this problem, a virtual model based motion control method is proposed for a quadruped robot walking on rough terrains. The mapping relationship between the high level locomotion task and low level motion control is built to satisfy the constraints of feet contact forces. The quadruped robot is built as a spring-damper-mass model. The locomotion task of the quadruped robot is represented using virtual forces acting on the mass centre of the body. A principle that all feet of the quadruped robot have balanced equivalent torques is assumed, based on which the virtual force vectors solved in Cartesian space are distributed to all supporting feet. The Jacobian matrix for each single leg is employed to convert the feet forces in Cartesian space into joint torques in joint space. As for rough terrains with 3D slopes, the trunk posture of the quadruped robot is changed according to the current terrain parameter so as to improve the robot's ability to adapt to highly-rough terrains. Dynamic simulations results show that the quadruped robot traverses the rough terrains successfully with small trunk undulations and steady ground forces on the feet. Therefore, the effectiveness of the presented compliant gait generation approach is proved.