On-the-fly just meant when required. QColor provides a method called fromHsv(). You calculate the designated hue and pass it to the function. The result is your color. Just calculate hue values in such way that neighboring colors in your list differ by 180 (degrees).