Albert Adomah’s winner clinched QPR’s Championship survival.
Adomah pounced on the loose ball to score after Lyndon Dykes’ shot had been parried by ex-Brentford keeper Jack Bonham.
Rangers knew a victory would make them safe from the drop – but Reading’s 1-1 draw with Wigan meant a point would have been enough for Gareth Ainsworth’s side.
They were recently on the brink of the bottom three but back-to-back wins have left them six points clear, having lost just one of their past five matches.
The upturn means they will go into the final match of the season, at home to Bristol City, without the threat of relegation hanging over them.
QPR: Dieng; Laird, Dunne, Dickie, Paal; Adomah (Martin 78), Field, Iroegbunam (Amos 64), Chair (Willock 89), Lowe, Dykes.
Subs not used: Archer, Drewe, Clarke-Salter, Johansen.