Electric field related to conducting materials containing charge containing cavity In my physics class we were analyzing a scenario where a charge has been placed inside the cavity of a conducting material like this:

What my teacher did was to assume a Gaussian surface in the conducting region, and a charge $x$ to be present in that region (along with the already-present $+q$ charge), and then apply Gauss's law. He told us that the electric field inside a conducting medium must always be $0$, and thus according to Gauss's law we get that $x=-q$. Thus a negative charge of magnitude $q$ develops on the walls of the cavity and a charge $-x=+q$ develops on the outer surface of the conductor (by conservation of charge). Thus the final diagram becomes like:

My teacher had demonstrated the fact that the electric field is always $0$ inside a conductor by using Gauss's law as follows:

My confusion is that in that scenario (in image 3), no charge was present in the conducting body, so how could we generalize that result? If we try doing the same with this scenario (in image 1), $Q_{inside S} \neq 0$ so we cannot predict the electric field. So my question is, how do you go about predicting the electric field in this case?
 A: Let's draw a couple of Gaussian surfaces (spheres for simplicity): a small one, surrounding the cavity inside the conductor, and a big one surrounding the conductor.

Since there is no electric field inside the conductor and the small sphere is fully inside the conductor, there won't be any electric flux (or electric field lines) passing through the small sphere. 
On the other hand, according to the Gauss law, there is a flux (electric field lines) passing through the big sphere:

Since there are no lines passing through the small sphere, they must originate from the charge (charges if you will) located somewhere outside the small sphere. The only place where such charge could reside is the outer surface of the conductor (since charges cannot exist in the bulk of the conductor). 
Of course, from the flux formula above, this charge should be +q, i.e., it must be equal to the charge inside the cavity. Since the total charge on the conductor was zero to start with, the negative charge on the surface of the cavity must be -q.
We could also conclude that the charge on the surface of the cavity is -q based on the fact that the flux through the small sphere is zero: zero flux implies zero charge inside the small sphere, which implies that the +q charge inside the cavity has to be cancelled by the charge on the surface of the cavity, which makes it -q.
In summary, although the total charge in (or, more precisely, on the surface of) the conductive body is zero, there is a non-zero, -q, charge on the surface of the cavity inside the body and there is a non-zero, +q, charge on the outer surface of the conductor.  
