This study uses high-fidelity simulations (direct numerical simulation or large-eddy simulation) and experimental datasets to analyse the effect of non-equilibrium streamwise mean pressure gradients (adverse or favourable), including attached and separated flows, on the statistics of boundary-layer wall-pressure fluctuations. The datasets collected span a wide range of Reynolds numbers ( $Re_\theta$ from 300 to 23 400) and pressure gradients (Clauser parameter from $-0.5$ to 200). The datasets are used to identify an optimal set of variables to scale the wall-pressure spectrum: edge velocity, boundary layer thickness and the peak magnitude of Reynolds shear stress. Using the present datasets, existing semi-empirical models of the wall-pressure spectrum are shown unable to capture effects of strong, non-equilibrium adverse pressure gradients, due to inappropriate scaling of the wall pressure using the wall shear stress, calibration with limited types of flows and dependency on model parameters based on the friction velocity, which reduces to zero at the detachment point. To address these shortcomings, a generalized wall-pressure spectral model is developed with parameters that characterize the extent of the logarithmic layer and the strength of the wake. Derived from the local mean streamwise velocity profile, these two parameters inherently carry the effect of the Reynolds number, as well as those of the non-equilibrium pressure gradient and its history. Comparison with existing models shows that the proposed model behaves well and is more accurate in strong-pressure-gradient flows and in separated-flow regions.