The invention relates to a process for treating keratin fibres, in particular human keratin fibres such as the hair, comprising:(i) a step of applying a compound (I)and also the acid or base salts thereof, the optical or geometrical isomers thereof,and the solvates thereof such as hydrates,in which compound of formula (I):R1, R2, R3, R4, x, m, n, X−;, are as defined in the description;(ii) a step of heating the keratin fibres to a temperature of at least 100° C., preferably ranging from 100 to 250° C.;it is understood that steps (i) and (ii) may be performed at the same time or separately.The process makes it possible to obtain good hair-conditioning cosmetic properties, with a long-lasting effect.The invention also relates to the novel compounds and to a cosmetic composition comprising such a compound.