Recent studies of the atmospheres of carbon-rich (DQ) white dwarfs have demonstrated the existence of two different populations that are distinguished by the temperature range, but more importantly, by the extremely high masses of the hotter group. The classical DQ below 10000 K are well understood as the result of dredge-up of carbon by the expanding helium convection zone. The high-mass group poses several problems regarding their origin and also an unexpected correlation of effective temperature with mass. We propose to study the envelopes of these objects to determine the total hydrogen and helium masses as possible clues to their evolution. We developed new codes for envelope integration and diffusive equilibrium that are adapted to the unusual chemical composition, which is not necessarily dominated by hydrogen and helium. Using the new results for the atmospheric parameters, in particular, the masses obtained using Gaia parallaxes, we confirm that the narrow sequence of carbon abundances with Teff in the cool classical DQ is indeed caused by an almost constant helium to total mass fraction, as found in earlier studies. This mass fraction is smaller than predicted by stellar evolution calculations. For the warm DQ above 10000 K, which are thought to originate from double white dwarf mergers, we obtain extremely low hydrogen and helium masses. The correlation of mass with Teff remains unexplained, but another possible correlation of helium layer masses with Teff as well as the gravitational redshifts casts doubt on the reality of both and suggests possible shortcomings of current models.