The integrating factor method is often successful in finding explicit closed-form solutions of standard problems. But, for certain problems other methods are known. Pfaff's Theorem states that there exists an integrating factor $I$ (not necessarily the standard one as discussed in the elementary DEqns course) which makes a first order ODE exact. However, finding $I$ is as difficult as finding the solution to the DEqn of interest. So, generically speaking one hopes for a clever substitution to appear since deriving the substitution is as hard as the problem itself. That said, I think this problem is more about integration than some other technique.
For your problem, if I assume $q=g$ (which may be mere wishful thinking on my part) then your problem becomes:
$$ \frac{d}{dt} [ yf ] = \frac{t}{f}\frac{df}{dt} $$
But, we can write this as,
$$ \frac{d}{dt} [ yf ] = t\frac{d}{dt} \ln(f) $$
Well, this is a lovely formula, I can integrate it and with the technique of integration by parts derive a nice solution up to an integral for the given problem,
$$ yf = t\ln(f)-\int \ln(f) dt $$
hence,
$$ y = \frac{1}{f} \biggl( t\ln(f)-\int \ln(f) dt +C \biggr). $$