Paul Smyth scored the winner on his QPR debut as Cardiff suffered a fourth consecutive defeat, going down 2-1 at Loftus Road.
Joe Ralls put Cardiff ahead with a penalty nine minutes into the second half after Jake Bidwell was adjudged to have pushed Callum Patterson.
But Matt Smith equalised on 62 minutes when he rose to head in Jack Robinson's long throw-in and Northern Ireland U21 international Smyth struck with 18 minutes remaining.
The 20-year-old forward, a summer signing from Linfield, skipped past defender Bruno Ecuele Manga on the left and fired home with the help of a slight deflection off Sol Bamba as the Cardiff captain slid in to try to block the shot.
There was controversy late on with former QPR man Junior Hoilett having a goal disallowed. Hoilett found the net after exchanging passes with Kenneth Zohore but was ruled offside.
Cardiff protested, seemingly arguing that a Rangers player had touched the ball before it ran to Hoilett, but referee Tim Robinson stood by the decision following a lengthy consultation with his assistant.
It meant an unhappy return to west London for Cardiff manager Neil Warnock, whose hopes of a record-breaking eighth promotion have been severely dented by his team's recent wobble.
His seventh was during an eventful two-year spell at QPR, who now find themselves trying to avoid a slide into League One - this was only their second win in 11 matches.
Rangers hit the woodwork twice before Smith hauled them level.
Four minutes before half-time, Smith headed against the post from Luke Freeman's free-kick and Freeman went close a couple of minutes before the equaliser when his shot struck the bar after taking a deflection off Bamba.
Smyth missed a decent chance seven minutes before the interval, scooping the ball over the bar when Alex Baptiste teed him up after exchanging passes with Massimo Luongo.
Otherwise, the youngster was outstanding, setting up chances for Smith and Luongo before scoring. He was cheered off the pitch by the home fans as he was substituted after picking up a knock soon after his goal.
Cardiff would have rescued a point but for an injury-time save by keeper Alex Smithies, who prevented a Smith own goal by clawing away the striker's mis-placed header.
Cardiff keeper Brian Murphy also produced a late save, denying substitute Aramide Oteh at point-blank range in the final seconds.
QPR: Smithies; Baptiste, Onuoha, Robinson; Cousins, Scowen, Luongo, Freeman, Bidwell (Lynch 85); Smyth (Oteh 77), Smith
Unused subs: Lumley, Chair, Osayi-Samuel, Sylla, Wszolek
Goals: Smith 62, Smyth 72
Bookings: Smyth 70, Freeman 90+3
Cardiff City: Murphy; Manga, Bamba, Connolly; Paterson, Peltier (Damour 58), Ralls, Bennett; Zohore; Healy (Mendez-Laing 67), Hoilett
Unused subs: Etheridge, Richards, Halford, Pilkington, Tomlin
Goal: Ralls pen 54
Bookings: Connolly 18, Peltier 50
Referee: Tim Robinson
Attendance: 13,801