He links up again with Harry Redknapp, who he served under at Portsmouth, and becomes the Hoops’ fifth summer signing joining Charlie Austin, Karl Henry, Richard Dunne and Danny Simpson at Loftus Road.
“The challenge here is an exciting one,” the midfielder told the club website.
“Obviously I know Harry well and he was a big factor in me coming here. The promotion season we had under him at Portsmouth was fantastic.
“He’s played a massive role in my development as a player and now I’m back playing for him again and I want to repay him by helping this club get back into the Premier League.”
Redknapp added: “Gary’s a good player and a good pro.
“He can run all day long, he’s good on the ball, a good passer, he sees all the pictures in front of him and is a top professional.”
O’Neil begun his career at Fratton Park, spending eight seasons with the south coast club, before moving to Middlesbrough and then West Ham.