Dispersions of nanoparticles (NPs) in a polymer matrix are a key element to set various properties of solution-cast polymer nanocomposite films. While the dispersion state of NPs in nanocomposite films has been extensively studied over the last decades, the structural development during drying and the relation of liquid and solid structure still remains poorly understood. In the present work, we study how NP dispersions develop during drying in polymer nanocomposite films, particularly focusing on the role of particle-polymer interaction in the structural development. Aqueous dispersions of nano-silica and poly(vinyl alcohol) are used as a model NP/polymer mixtures, where the particle-polymer interaction can systemically be varied via the pH. A novel vertical small angle X-ray scattering technique enables us to directly observe the development of NPs dispersion during drying. At a high pH 10, where silica particles have a poor affinity to PVA, SAXS intensity evolution shows phase separation during drying, resulting in the formation of dense aggregates of bare particles in the solid film. On the other hand, at a low pH 3, where silica particles have a good affinity with PVA, the SAXS data indicates a gradual densification of the NPs while maintaining a constant inter-particle distance, which is originating from adsorbed PVA. The resulting solid film after drying exhibits an improved dispersion of NPs. The evaluation of the inter-particle interaction suggests that the adsorbed polymer plays generally a key role in the uniform distribution of NPs in solid films, as it sterically stabilizes NPs over short ranges during all drying stages whereas depletion attraction dominates at longer ranges.