In symbols, Q, or q, in thermodynamics, is the symbol for heat, or specifically “quantity of heat” (Lavoisier, 1783), in the sense of “quantity”, from the Latin quantus ‘how much’. [1]

Overview
In early 1750s, Joseph Black had discovered the concepts of latent heat, i.e. that when a body makes a phase change, e.g. solid to liquid, a large amount heat is going into or out of the body, yet as discerned by the thermometer there is no detection of this heat flow, because temperature reads constant for the entire process, and specific heat, i.e. that each type of body has a unique or “specific” ability or “capacity” to hold or contain heat, e.g. wood as compared to iron. The method he used to measure the heat capacity (specific heat) of bodies is what is now called the law of mixtures:

Law of mixtures: two bodies of equal mass but different temperature are mixed together; their heat capacities vary inversely as the changes each undergoes on reaching the final temperature of the mixture.”
— Henry Guerlac (1982), “Introduction” to Lavoisier and Laplace’s 1783 Memoir on Heat (pg. xiv)

In 1766, Black, at the University of Edinburgh (Ѻ), as chair of chemistry and medicine, gave a series of overly-popular lectures, wherein he outlined his theories of “quantity of heat”, as opposed to older model of “intensities of heat” (thermometry); the following is one example:

“If, for example, we have one pound of water in one vessel, and two pounds in another, and these two quantities of water are equally hot, as examined by the thermometer, it is evident, that the two pounds must contain twice the ‘quantity of heat’ that is contained in one pound. But, undoubtedly, we can suppose that a cubical inch of iron may contain more heat than a cubical inch of wood, heated to the same degree; and we cannot avoid being convinced of this by daily experience.”
Joseph Black (c.1766), Lectures on Chemistry (pg. 75) [4]

Black’s lectures were eventually published by his students and his experiments and “quantity of heat” theories were carried out more by his student William Irving; Irving’s work, in turn, influenced Adair Crawford, as evidenced in his Experiments and Observations on Animal Heat (1779), which had a “profound influence” (Guerlac, 1982) on Antoine Lavoisier and Joseph Laplace.

In 1783, Lavoisier and Laplace, in the opening pages of their “Memoir on Heat”, went to derivation, wherein using a “law of mixing” argument, they defined a unit of heat, that can pass form a hot body of water to a cold body of mercury, thereby bringing about a new temperature at equilibrium, as follows:

“Let ‘q’ be the heat necessary to raise the temperature of one pound of a substance by one degree on a mercury thermometer.”
— Antoine Lavoisier (1783), “Memoir on Heat” (co-author: Joseph Laplace) (pg. 7)

In 1834, Emile Clapeyron, in his “Memoir on the Motive Power of Heat”, adopted this use of q for heat. [3]

In 1850, Rudolf Clausius, building on Clausius used capital Q for the unit of heat; hence, its modern use in thermodynamics.

Note
Related to “quantity of heat”, is that of “intensity of heat” or “degree of heat” which is a distinct concept known as temperature, symbol T. [2]

Quotes
The following are related quotes:

Law of mixtures. The science of the measurement of quantities of heat is called ‘calorimetry’, and the piece of apparatus used for the purpose is called ‘calorimeter’.”
— Robert Houstoun (1928), Intermediate Heat (pg. 37)

Black’s great achievements were to set up the fundamental concept of quantity of heat and, by considering its implications, infer the correlative concepts of ‘heat capacity’ and ‘latent heat’. Having done all this by about 1760, and having also seen the importance of the two latter concepts in the processes of nature, Black did nothing further; he did not even publish his discoveries.”
Donald Cardwell (1971), From Watt to Clausius (pg. 40) [2]

Carnot himself did not use a symbol for the quantity of heat [correctly he used small "s" for heat] in his original memoir of 1824, which was largely verbal rather than mathematical in character, and Clapeyron most likely selected the letter Q to emphasize that he was dealing with the quantity of heat rather than with its intensity or temperature, for which he used an uppercase T. Building on the work of Clapeyron, in the 1850s and 1860s, Clausius not only continued to use Q to symbolize heat in his various memoirs on the theory of heat, he also employed an upper-case W to represent mechanical work.”
William Jensen (2010), “Why are q and Q used to Symbolize Heat?” [2]

References
1. Lavoisier, Antoine; Laplace, Pierre. (1783). Memoire on Heat (Memoire sur la Chaleur) (translator: Henri Guerlac) (§: Introduction, pgs. vii-xvii; q is ‘quantity of heat’, pgs. 7-8). Academic Press, 1982.
2. Cardwell, Donald S.L. (1971). From Watt to Clausius: the Rise of Thermodynamics in the Early Industrial Age (quantity of heat vs degree of heat, pg. 31). Cornell University Press.
3. Jensen, William R. (2010). “Why are q and Q used to Symbolize Heat?” (pdf), Journal of Chemical Education, 87(11):1114.
4. Black, Joseph. (1786). Lectures on the Elements of Chemistry: Delivered in the University of Edinburgh, Volume One (editor: John Robinson) (quantity of heat, 13+ pgs). Publisher, 1807.