  We study isospin-1 P-wave $\pi\pi$ scattering in lattice QCD with two
flavours of O($a$) improved Wilson fermions. For pion masses ranging from
$m_\pi=265$ MeV to $m_\pi=437$ MeV, we determine the energy spectrum in the
centre-of-mass frame and in three moving frames. We obtain the scattering phase
shifts using L\"uscher's finite-volume quantisation condition. Fitting the
dependence of the phase shifts on the scattering momentum to a Breit-Wigner
form allows us to determine the resonance parameters $m_\rho$ and
$g_{\rho\pi\pi}$. By combining the scattering phase shifts with the decay
matrix element of the vector current, we calculate the timelike pion form
factor, $F_\pi$, and compare the results to the Gounaris-Sakurai representation
of the form factor in terms of the resonance parameters. In addition, we fit
our data for the form factor to the functional form suggested by the Omn\`es
representation, which allows for the extraction of the charge radius of the
pion. As a further application, we discuss the long-distance behaviour of the
vector correlator, which is dominated by the two-pion channel. We reconstruct
the long-distance part in two ways: one based on the finite-volume energies and
matrix elements and the other based on $F_\pi$. It is shown that this part can
be accurately constrained using the reconstructions, which has important
consequences for lattice calculations of the hadronic vacuum polarisation
contribution to the muon anomalous magnetic moment.
