Joint formation of QSOs and spheroids: QSOs as clocks of star formation in spheroids