Is Q here the set of rational numbers? If so, then no, the set of rational numbers is not connected and the intermediate value theorem, in a more abstract setting, essentially says that if f is continous then it maps aconnectedset to aconnectedset. (In the real numbers, a set is connected if and only if it is an interval. There arenoconnected subsets of the rational numbers.)