Older and more recent pieces of observational evidence suggest a strong con
nection between QSOs and galaxies; in particular, the recently discovered c
orrelation between black hole and galactic bulge masses suggests that QSO a
ctivity is directly connected to the formation of galactic bulges. The cosm
ological problem of QSO formation is analysed in the framework of an analyt
ical model for galaxy formation; for the first time a joint comparison with
galaxy and QSO observables is performed. In this model it is assumed that
the same physical variable that determines galaxy morphology is able to mod
ulate the mass of the black hole responsible for QSO activity. Both halo sp
in and the occurrence of a major merger are considered as candidates for th
is role. The predictions of the model are compared with available data for
the type-dependent galaxy mass functions, the star formation history of ell
iptical galaxies, the QSO luminosity function and its evolution (including
the obscured objects contributing to the hard-X-ray background), the mass f
unction of dormant black holes and the distribution of black hole-to-bulge
mass ratios. A good agreement with observations is obtained if the halo spi
n modulates the efficiency of black hole formation, and if the galactic hal
oes at z = 0 have shone in an inverted order with respect to the hierarchic
al one (i.e., stars and black holes in bigger galactic haloes have formed b
efore those in smaller ones). This inversion of hierarchical order for gala
xy formation, which reconciles galaxy formation with QSO evolution, is cons
istent with many pieces of observational evidence.