We study the scaling of the decoherence factor of a qubit (spin-1/2) using the central spin model in which the central spin (qubit) is globally coupled to a transverse XY spin chain. The aim here is to study the nonequilibrium generation of decoherence when the spin chain is driven across (along) quantum critical points (lines) and derive the scaling of the decoherence factor in terms of the driving rate and some of the exponents associated with the quantum critical points. Our studies show that the scaling of the logarithm of the decoherence factor is identical to that of the defect density in the final state of the spin chain following a quench across isolated quantum critical points for both linear and nonlinear variations of a parameter, even if the defect density may not satisfy the standard Kibble-Zurek scaling. However, one finds an interesting deviation when the spin chain is driven along a critical line. Our analytical predictions are in complete agreement with numerical results. Our study, though limited to integrable two-level systems, points to the existence of a universality in the scaling of the decoherence factor which is not necessarily identical to the scaling of the defect density. © 2012 American Physical Society.