We explore the weak lensing effect by line-of-sight haloes and subhaloes with a mass of M ≲ 107 M⊙ in Quasi-Stellar Object (QSO)–galaxy strong lens systems with quadruple images in a concordant Λ cold dark matter universe. Using a polynomially fitted non-linear power spectrum P(k) obtained from N-body simulations that can resolve haloes with a mass of M ∼ 105 M⊙, or structures with a comoving wavenumber of k ∼ 3 × 102 h Mpc−1, we find that the ratio of magnification perturbation due to intervening haloes to that of a primary lens is typically ∼10 per cent and the predicted values agree well with the estimated values for six observed QSO–galaxy lens systems with quadruple images in the mid-infrared band without considering the effects of substructures inside a primary lens. We also find that the estimated amplitudes of convergence perturbation for the six lenses increase with the source redshift as predicted by theoretical models. Using an extrapolated matter power spectrum, we demonstrate that small haloes or subhaloes in the line of sight with a mass of M = 103–107 M⊙, or structures with a comoving wavenumber of k = 3 × 102–104 h Mpc−1, can significantly affect the magnification ratios of the lensed images. Flux-ratio anomalies in QSO–galaxy strong lens systems offer us a unique probe into the clustering property of minihaloes with a mass of M < 106 M⊙.