In every appearance he has demonstrated superior capabilities, but also a mind-set that seems quite unlike what Federation scientists expect for such a powerful being. He has been described, in turn, as "obnoxious," "interfering," and a "pest." However, underneath his acerbic attitude, there seems to be a hidden agenda to Q's visits that seem to have the best interests of Humanity at their core — although this opinion cannot be directly proven.
He was first encountered by the Federation when he appeared aboard the USS Enterprise-D in early 2364. He warned the crew of the Enterprise that Humanity should return to their home solar system or be destroyed, and when he encountered resistance, he placed Humanity on trial with Jean-Luc Picard and his command crew as representatives. He accused Humanity of being a "dangerous, savage child-race." Picard managed to strike a deal with Q, however, and submitted to a test of conduct to prove that Humanity had evolved beyond its previously savage state. The Enterprise's mission to Farpoint Station served as this test. When the Starfleet crew sufficiently proved their evolved state of being by discovering and assisting a shapshifting alien that had been coerced by the Bandi to take the form of a starbase, Q disappeared. (TNG: "Encounter at Farpoint")
The next time Q appeared on the Enterprise later that year, he created a bizarre and deadly "game" for the ship's crew, in order to demonstrate that he had given Commander Riker Q-like abilities. Ultimately, Riker rejected these new powers, and Q again disappeared. (TNG: "Hide and Q")
In his third appearance in 2365, Q first expressed an interest in joining Picard's crew. When Picard declined, Q tried to show how much he could be of assistance by hurling the Enterprise into the path of a Borg Cube. Q was hoping to show the Federation that it was entirely unprepared to meet some of the more powerful races that existed in the universe. Ultimately, Picard had to beg for Q's help in escaping from the pursuit of the Borg ship.
Interestingly, in this encounter Q alluded to a past association with Enterprise bartender Guinan; Guinan has declined to elaborate on the nature of her relationship other than express her extreme dislike for Q. Based on Q's reactions, the sentiment seems mutual. (TNG: "Q Who?")
In 2366, Q was stripped of his omnipotence and immortality and transformed into a Human by the Q Continuum as punishment for his irresponsibility. He sought refuge on the Enterprise, requesting asylum and protection from those beings in the universe whom he had tormented. Although Captain Picard and the rest of the crew were unconvinced of the sincerity of Q's plea (and indeed whether the entire situation was an elaborate prank), Picard agreed to provide Q temporary asylum. During this time, Data was assigned to watch Q, and Q gained an unusual perspective on Humanity and its condition. However, after a Calamarain attack nearly destroyed Data, Q resolved to end his life in order to prevent further risk to the Enterprise crew. However, another Q prevented Q from sacrificing himself, and restoring Q's powers as a reward for his selfless act. In gratitude, Q restored the orbit of the Bre'el IV moon, which was in danger of colliding with its primary — an event which the Enterprise crew was trying to prevent. Q also gave a special gift to Data, his "professor of the Humanities" — a brief moment of laughter. (TNG: "Deja Q")
Late in 2367, Q returned to the Enterprise to "properly" thank Captain Picard for his role in helping him regain his standing in the Continuum. At the time, Picard was meeting a friend named Vash, whom he'd met on Risa the year before. Q resolved to teach Picard a lesson about love, and cast Picard, Vash, and the Enterprise command crew into an elaborate scenario styled by the ancient legend of Robin Hood. Q himself assumed the role of the Sheriff of Nottingham. Ultimately, Picard learned his lesson, and everyone was returned to the Enterprise. Intrigued by Vash, though, Q offered to take her on a journey of exploration to explore various archaeological ruins of the galaxy, and she accepted. (TNG: "QPid")
In 2369, Q once again appeared aboard the Enterprise-D, this time to instruct Amanda Rogers, a Human female who was the child of two Q and who possessed Q powers herself. Although Q's petulant and acerbic attitude did little to ingratiate himself to Amanda, he eventually convinced her to go with him to the Continuum to learn to use her newfound abilities. (TNG: "True-Q")
Although Vash had agreed to travel with Q, she decided to leave him after exploring in the Gamma Quadrant later in 2369. She claimed that she didn't trust him, and that he was as arrogant and obnoxious as she'd been told before. Vash returned to the Alpha Quadrant through the Bajoran wormhole, and Q followed. Q persistently asked Vash to continue traveling with him, and amused himself by provoking the crew of Deep Space 9 when she refused. Eventually, Q simply tired of the games and left. (DS9: "Q-Less")
Later that same year, Q appeared to Jean-Luc Picard when the latter was critically injured in a Lenarian ambush. Appearing as "God", Q told Picard that he had died because of his artificial heart, and offered him the chance to return to the incident in his youth, allowing him to relive the events leading up to his near-fatal injury and change history. Although Picard was successful in changing history, he eventually realized that the event — and his previous nature as an arrogant, brash young man — was a part of his identity, and had helped mold him into the successful Starfleet officer he had become. Although he was uncertain as to whether the experience had been real or simply a vision, Picard was grateful for Q's revelation. (TNG: "Tapestry")
In 2370, Q returned to the Enterprise to continue the trial against Humanity. Claiming that the seven-year-old trial had never actually ended, Q proclaimed Humanity guilty of "being inferior" and informed Picard that his race was to be destroyed. He sent Picard traveling through time to his past, present, and future, where he was presented with a temporal paradox, in the form of an eruption of anti-time in the Devron system. In this paradox, Picard himself was responsible for the creation of the anomaly, that propagated backwards in normal time (anti-time having the opposite properties of normal time), thus destroying Humanity in the past.
However, in addition to sending Picard jumping through time, Q also provided Picard with hints to understanding the nature of the paradox. Ultimately, Picard determined the solution and devised a way to close the anti-time anomaly in all three time periods. Following the success, Q revealed that the entire experience was a test, aimed at determining whether Humanity was capable of expanding its horizons to understand some of the advanced concepts of the universe. Departing, Q promised to continue watching Humanity, proclaiming that "the trial never ends." (TNG: "All Good Things...")
In 2372, Q was sent by the Continuum to board the USS Voyager, whose crew had unintentionally released a renegade Q from confinement in a rogue comet. When the other Q (later known as Quinn) asked for asylum on Voyager in order to fulfill his wish to commit suicide (an act considered illegal in the Continuum), Q was permitted to represent the Continuum at the hearing. Q argued that permitting a Q to commit suicide would cause unspeakable chaos and disorder — a profound irony considering Q's own history as a prankster and renegade. (When confronted with his past deeds, Q commented that "[his] record has been expunged.")
Ultimately, Quinn's arguments prevailed, and he was made into a mortal being. Q himself was touched by Quinn's dedication and beliefs — Quinn had previously been an admirer of Q's, because of Q's propensity to stir controversy and cause disorder — and actually provided Quinn with the means with which to commit suicide. Q resolved to return to some of his old habits, and to encourage the Continuum to allow more chaos in their own order. (VGR: "Death Wish")
Following the death of Quinn, a massive Q Civil War broke out, as the forces of the status quo resisted the calls for change in the Continuum, by a faction led by Q himself. Seeking to end the conflict, Q devised a plan to mate with Kathryn Janeway, the captain of Voyager, in order to create a new Q/Human hybrid — a new breed of Q that would help bring an end to the civil war. Janeway, however, flatly refused. Q then kidnapped Janeway to the Continuum, where he again tried to persuade her by explaining the nature of the conflict. However, Janeway again declined, and attempted to negotiate a truce between the two sides. These negotiations failed, however, because the status quo faction refused to accept any terms other than surrender. They attempted to execute both Q and Janeway, but they were stopped by personnel from Voyager with the assistance of a female Q, an old flame of Q's. Q then proposed mating with his old girlfriend instead, and she agreed. The new child, nicknamed "Junior", became the first child born in the Continuum in millennia, and his presence brought an end to the civil war. (VGR: "The Q and the Grey")
Q's child, however, did not prove to become the perfect "savior" child that he was meant to be. "Junior" grew into a spoiled brat, causing even more chaos and disorder than his father's pranks ever did. Q tried to briefly leave his son with Janeway aboard Voyager, hoping that Janeway's sense of "Starfleet ideals" would rub off on him. Q himself begins to learn more about the role of being a parent. However, after spending years with the child, "Junior" only began to behave worse. As a result, Q stripped his son of his powers and left him aboard Voyager again under the care of Janeway, telling him to reform his ways within a week or be sentenced by the Continuum to spend eternity as an Oprelian amoeba.
Although Q was initially unimpressed by his son's progress, he devised a test of "Q-ness" to determine whether his son had improved his attitude. He masqueraded as a Chokuzan captain and threatened Junior and his friend Icheb after they stole the Delta Flyer from Voyager. Junior passed with flying colors, offering to sacrifice himself to face the consequence of his actions, which had endangered Icheb.
However, the Continuum was not impressed by Junior's progress, and sentenced him to remain Human. Outraged, Q proclaimed that he would leave the Continuum if his son were not allowed to rejoin. The Continuum acquiesced, on one condition — that Q retain eternal custody of the boy. Grateful for her assistance, Q provided Janeway with a map to a shortcut to the Alpha Quadrant that would shorten Voyager's journey home. (VGR: "Q2")