Dynamics of an inhomogeneous quantum phase transition