The possibility to detect circumbinary planets and to study stellar magnetic fields through binary stars has sparked an increase in the research activity in this area. In this paper we revisit the connection between stellar magnetic fields and the gravitational quadrupole moment $Q_{xx}$. We present three magnetohydrodynamical simulations of solar mass stars with rotation periods of 8.3, 1.2, and 0.8 days and perform a detailed analysis of the magnetic and density fields using a spherical harmonic decomposition. The extrema of $Q_{xx}$ are associated with changes of the magnetic field structure. This is evident in the simulation with a rotation period of 1.2 days. Its magnetic field has a much more complex behaviour than other models as the large-scale non-axisymmetric field dominates throughout the simulation and the axisymmetric component is predominantly hemispheric. This triggers variations in the density field that follow the magnetic field asymmetry with respect to the equator, changing the $zz$ component of the inertia tensor, and thus modulating $Q_{xx}$. The magnetic fields of the other two runs are less variable in time and more symmetric with respect to the equator such that there are no large variations in the density, therefore only small variations in $Q_{xx}$ are seen. If interpreted via the classical Applegate mechanism (tidal locking), the quadrupole moment variations obtained in the simulations are about two orders of magnitude below the observed values. However, if no tidal locking is assumed, our results are compatible with the observed eclipsing time variations.