Championship leaders Cardiff fell to their first home league defeat of the season after QPR substitute Ray Jones slid in to score an 88th-minute goal.
QPR have been revived by manager John Gregory
Australian Nick Ward played a key part in the goal, beating Joe Ledley and Kevin McNaughton before crossing to Jones who poked the ball home.
McNaughton had come desperately close to giving Cardiff the lead after he struck the bar with a curling shot.
QPR had the best first-half chances, notably through a Lee Cook shot.
Cardiff manager Dave Jones:
"They came to do a job and they have taken away the points.
"If you are not going to win then you have to make sure you do not lose.
"I have no complaints, because we started poorly and finished poorly, and there were not enough attempts on goal.
"They got the goal without any sustained pressure. It was bad defending on our part."
QPR manager John Gregory:
"I've been so proud of them since I became manager.
"This group of players is a pleasure to be around and they're a fantastic bunch of lads.
"They've a tremendous work ethic and throughout the game you could see them backing each other up.
"Given the number of goals we've conceded, we did very well defensively."
Cardiff: Alexander, Gunter, Purse, Loovens, McNaughton, Parry (Kamara 81), McPhail, Scimeca, Ledley, Thompson, Chopra.
Subs Not Used: Howard, Johnson, Cooper, Campbell.
QPR: Royce, Mancienne, Rehman, Stewart, Bignot, Ainsworth (Ward 15), Bailey, Smith, Cook, Nygaard, Blackstock (Ray Jones 65).
Subs Not Used: Paul Jones, Milanese, Baidoo.
Booked: Bignot, Nygaard, Bailey.
Goals: Ray Jones 88.
Ref: P Joslin (Nottinghamshire).