The ancestry of the Q character is rather complicated. In the Ian Fleming novels there are frequent references to ‘Q Branch’, with a reference to “Q’s craftsmen” in From Russia with Love.
In the sixth novel, Dr No, the service armourer Major Boothroyd appears for the first time.
Fleming named the character after Geoffrey Boothroyd, a firearms expert who lived in Glasgow, Scotland. He had written to him suggesting that Bond was not using the best firearms available. Boothroyd is also referenced occasionally in the Bond novels of John Gardner, but the author preferred instead to focus on a new character.
In the films, Major Boothroyd first appears in Dr No and later in From Russia with Love, although played by different actors. Beginning in Goldfinger and in each film thereafter Major Boothroyd is referred to as Q, however, in The Spy Who Loved Me (1977) he is referred once again as Major Boothroyd in dialogue. Some sources, most notably the 1980s James Bond 007 role-playing game suggested that Boothroyd’s first name was Geoffrey (the real Boothroyd’s given name), although no first name was ever mentioned in the novels or on screen.