Quantum Grothendieck rings and derived Hall algebras