You need to read this article . Jokes aside.
In addition, all that may be required is to QColor::fromHslF(x/*0.8, 0.95, 0.5) over the shades in the HSL color representation using QColor::fromHslF(x/*0.8, 0.95, 0.5) where x varies from 0.0 to 1.0 over the rainbow. It is physically not entirely accurate, but perhaps it will do.
Otherwise, you will need a bit more complex code that approximates the above article very simplified.

source share