The present invention relates to novel quinoline compounds of the formula (I) and to the salts thereof. The compounds possess valuable therapeutic properties and are particularly suitable, for treating diseases that respond to modulation of the serotonin 5-HT6 receptor. In formula (I) R is a moiety of the formula (R) wherein * indicates the binding site to the quinolinyl radical and wherein A, B, X′, Y, Q, R1, R2, R3, R4, R5, m, n, p, q, Ra, Rb, X and Ar are as defined in claim 1.