The computing method of the average optimal position is one of the most important factors that affect the optimization performance of the QPSO algorithm. Therefore, a particle position weight computing method based on particle fitness value grading is proposed, which is called HWQPSO (hierarchical weight QPSO). In this method, the higher the fitness value of a particle, the higher the level of the particle, and the greater the weight. Particles at different levels have different weights, while particles at the same level have the same weight. Through this method, the excellent particles have higher average optimal position weight, and at the same time, the absolute weight of a few particles is avoided, so that the algorithm can quickly and stably converge to the optimal solution, and improve the optimization ability and efficiency of the algorithm. In order to verify the effectiveness of the method, five standard test functions are selected to test the performance of HWQPSO, QPSO, DWC-QPSO and LTQPSO algorithm, and the algorithms are applied to the task scheduling of the cloud computing platform. Through the test experiment and application comparison, the results show that the HWQPSO algorithm can converge to the optimal solution of the test function faster than the other three algorithms. It can also find the task scheduling scheme with the shortest time consumption and the most balanced computing resource load in the cloud platform. In the experiment, compared with QPSO, DWC-QPSO and LTQPSO algorithm, HWQPSO execution time of the maximum task scheduling was reduced by 35%, 23% and 21% respectively.