We determine the energy-dependent amplitude for elastic $\ensuremath{\pi}\ensuremath{\pi}$ $P$-wave scattering in isospin-1 by computing part of the discrete energy spectrum of QCD in finite cubic boxes. We observe a rapidly rising phase shift that can be well described by a single $\ensuremath{\rho}$ resonance. The spectrum is obtained from hadron correlators computed using lattice QCD with light quark masses corresponding to ${m}_{\ensuremath{\pi}}\ensuremath{\sim}400\text{ }\text{ }\mathrm{MeV}$. Variational analyses are performed with large bases of hadron interpolating fields including, as well as fermion bilinears that resemble $q\overline{q}$ constructions, also operators that resemble pairs of pions with definite relative and total momentum. We compute the spectrum for a range of center-of-mass momenta and in various irreducible representations of the relevant symmetry group. Hence we determine more than 30 values of the isospin-1 $P$-wave scattering phase shift in the elastic region, mapping out its energy dependence in unprecedented detail.