$\mathbb Q$ is not the direct product of two non-trivial groups.
Yes, your proof is correct. You can avoid proof by contradiction though (which IMO is a good thing to do): write $\mathbb{Q} = G \times H$. WLOG $G$ is nontrivial. Then your argument shows that $\pi_G$ is injective, but its kernel is $0 \times H$, therefore $H$ is trivial. QED.
Is there a specific part of your proof that made you doubt whether it was correct?
HINT:
Any two non-zero subgroups have a non-zero intersection, since any two non-zero elements have a common multiple.