The optical variability of QSOs .2. The wavelength dependence