To determine the intensity of a rotation-vibration transition, you need to consider the transition momentum integral $\int \psi_f \hat{\mu} \psi_i d\tau$, where $\psi_f$ is the final state, $\psi_i$ is the initial state, $\hat{\mu}$ is the transition dipole moment operator, and $d\tau$ indicates integration over all space. Assuming separation of vibrational and rotational motion, this factors into the product of two terms: one that specifies the intensity of the vibrational transition and another that specifies the intensity of the rotational transition. The vibrational integral leads to a selection rule $\Delta v = \pm 1$ (in the harmonic approximation) and the rotational integral leads to a selection rule $\Delta J = \pm 1$. So no Q branch occurs. However, if there is some additional source of angular momentum (e.g., from vibrations or electronic motion) then it is possible to have a Q branch because now that extra motion can contribute to the total angular momentum in a way that allows the Q branch to occur.
So here is the rule that you ask for: a Q branch will not occur in transitions between $\Sigma$ electronic states of a diatomic molecule, but can occur in transitions between $\Sigma$ and $\Pi$ states. Since vibration-rotation transitions by definition occur within a single electronic state, Q branches do not occur in vibration-rotation spectra of diatomic molecules in a $\Sigma$ state. In a polyatomic molecule, however, vibrational modes can carry angular momentum so even within a single electronic state that carries no electronic angular momentum it may be possible to observe Q branches in a vibration-rotation spectrum so long as the vibration being excited is one which carries nuclear orbital angular momentum (e.g., from a vibrationless ground state to a vibrationally excited bending mode).