For the Pirates, this move is a response to earlier deals. The trade of Brad Lincoln to the Blue Jays for Travis Snider created an opening in the Pirates' bullpen, and the trade of Gorkys Hernandez and a competitive-balance pick for Gaby Sanchez, a righty-hitting first baseman, made McGehee superfluous.
Losing McGehee is no big deal; Sanchez is better than he is (although by how much is an open question), and younger. But Qualls is terrible -- he couldn't post flashy numbers last year even in the pitcher's paradise of San Diego, and this year, he's striking out a measly 4.89 batters per nine innings. I'd prefer to see a younger, and arguably better, pitcher like Bryan Morris or Chris Leroux in the Pirates' bullpen rather than a veteran who's been flailing for a couple years now.
For more on the Pirates, check out Bucs Dugout.