Q was never anything other than a cut-rate Deux Ex Machina. "We need an unbeatable foe, an unsolvable puzzle, a limitless intellect and be so unassailable that even the boundless technobabble of the 23rd century cannot explain it away." And BANG! You get Q.