The present invention relates to novel quinolinecompounds of the formula (I) and to the salts thereof. Thecom-pounds possess valuable therapeutic properties and are particu-larlysuitable, for treating diseases that respond to modulation ofthe serotonin 5-HT6 receptor. In formula (I) R is a moiety of theformula (R) wherein * indicates the binding site to the quinolinylradical and wherein A, B, X', Y, Q, R1, R2, R3, R4, R5, m, n, p, q,R a, R b, X and Ar are as defined in claim 1.