Weighted composition operators on Dirichlet-type spaces and related $Q_p$ spaces