consider the map from Q[x] to Q(α) given by: p(x)-->p(α). this is a ring homomorphism.
furthermore, since α is algebraic over Q (it satisfies f(x) in Q[x]), Q[a] = Q(α) (that is, Q[α] is actually a FIELD).
now the image of this homomorphism contains Q (we can take as the pre-image of q in Q the constant polynomial q) and α (which has pre-image x), and is therefore surjective.
by the fundamental isomorphism theorem (for rings), Q(α) = Q[x]/I, for some ideal I of Q[x] (namely, the kernel of our homomorphism).
now Q[x] is a principal ideal domain, so I is generated by some polynomial, h(x) in Q[x].
since f(x) is in the kernel (since f(α) = 0), we have f(x) = h(x)k(x), for some polynomial k(x) in Q[x].
but f(x) is irreducible, so k(x) must be a unit (that is, an element of Q*). but then f(x) = qh(x), so h(x) = (1/q)f(x).
this means that (h(x)) = (f(x)).
now g(α) is also in the kernel, which is generated by f(x), so g(x) = f(x)s(x), for some polynomial s(x) in Q[x], that is: f|g.