This is not true. The first issue is that not every hom-functor $Hom(Q,-)$ preserves direct sums (I need to mention this even though Hartshorne did not claim this explicitly.). It is true when $Q$ is finitely generated but not in general. See 78161 for more info.
What is true in general is that $Hom(Q,-)$ preserves direct products. It is also left exact, so it preserves all limits. In other words, it is a continuous functor.
It is true that every continuous functor on the category of modules is of the form $Hom(Q,-)$, that is, it is representable. This follows from Freyd's special adjoint functor theorem.
Now here is a counterexample to the claim by Hartshorne. Notice that every filtered colimit of representable functors preserves finite limits. It preserves arbitrary direct sums when the representable functors do so. But the colimit functor doesn't have to be representable. The standard example is the torsion subgroup of an abelian group, being the colimit of the representable functors $Hom(\mathbb{Z}/n,-)$. This functor $Tor$ is not representable, because it does not preserve infinite products.
PS. There are many books on algebraic geometry that are better than Hartshorne. See MO/2466. There in the comment section you will also find other conceptual mistakes in Hartshorne's book. I also wrote about the mistakes here, there, and there.