Qt manually create color ramp rectangular QIcon

I want to create a rectangular QIcon (say, 128 x 16), with pixel colors I will fill manually with a color ramp.

To do this I thought of manually creating a QPixmap of size 128 x 16 and filling it manually, and then creating the QIcon from it.

Is this correct? Is there a better way of doing so?


What I already have in memory is an std::vector<> with all the colors in the ramp. Is there a way to use this directly?