Charlie Austin marked his QPR return with a goal to help give them a first win in 11 matches.
Macauley Bonne’s cool last-minute finish sealed the victory for Rangers.
Striker Austin, making his first appearance since rejoining the club, nodded home from close range after Ilias Chair’s left-wing corner had been headed on at the near post by Geoff Cameron.
Earlier, Lyndon Dykes was denied by keeper Simon Sluga after being put through by Austin, who played an hour.
Another Chair corner almost led to a second-half goal for Rob Dickie, who headed just over.
Bonne slotted into the bottom corner after being set up by fellow substitute Albert Adomah.
QPR: Dieng, Dickie, Cameron, Barbet, Kakay, Ball, Carroll, Chair (Adomah 74), Osayi-Samuel, Dykes (Kelman 90), Austin (Bonne 59).
Subs not used: Lumley, Hamalainen, Masterson, Bettache, Thomas, Willock.