Green, who has 12 caps, will arrive at Loftus Road on July 1 when his contract with West Ham expires.
"I'm delighted to be here," he said.
"I'm excited about the challenge ahead and hugely encouraged by the direction in which the owners and Mark Hughes are looking to take the club.
"It's an exciting period for everybody connected to QPR and I can't wait to get started."
Manager Hughes feels his squad is immediately strengthened with the signing.
"It was important we brought another quality keeper into the group," he said.
"Rob is obviously someone with vast experience at international and Premier League level and his pedigree speaks for itself.
"He's got all the characteristics of a top keeper and he'll be a huge addition for us who will stimulate the goalkeeping group, which can only be good for the squad as a whole."