Try $q(x) = (x^2+1)^3$ with $n = 6$.  The space of polynomials $p(x)$ such that $\int_0^1 \frac{p(x)}{q(x)} \; dx \in \mathbb Q \pi$ is infinite-dimensional.  If you meant polynomials of degree $< n$, that has dimension $4$, as the   
following $4$ linearly independent polynomials $p(x)$ qualify:
$$ 4 x - 3, x^2, 4 x^3 - 1, x^4 + 1 $$
Note that, if $J_n = \int_0^1 x^n/q(x)\; dx$, we have the recurrence 
$$J_{n+6} + 3 J_{n+2} + 3 J_{n+1} + J_n - \frac{16}{2(n+1)} J_1 = 0$$
Thus there are polynomials of all degrees $\ge 6$ that satisfy the condition.

Similarly, for your $q(x) = x^4+2x^3+2x^2-2x+1$, there are $p(x)$ with all degrees $\ge 5$ that satisfy the condition.