The QR decomposition (QRD)-based relaying protocol can achieve both the distributed array gain and the intra-node array gain in multi-input multi-output multi-relay systems. In this paper, the distributed precoding technique is first utilised in the QRD-based multi-relay system to further improve the capacity performance of the system. In order to find the optimum distributed precoder, a novel version of the particle swarm optimisation (PSO) algorithm is presented by redefining the evolution of particles on the spherical surface. Then, the complexity analysis of the proposed PSO algorithm is carried out to show its feasibility. Finally, numerical and simulation results demonstrate the performance gain of the proposed design in terms of the ergodic capacity.