painting a grayscale image into label

How do i use
QImage convertToFormat
& set color

I need to make whatever is black in the image and make it transparent
& whatever is white or partially white and make another color
Qt Code:
  1. while(x < secondaryImage.height()){
  2. while(y < secondaryImage.width()){
  3. if (secondaryImage.pixel(x,y) == 0)
  4. secondaryImage.setPixel(x, y, Qt::red);
  5. y++;
  6. }
  7. x++;
  8. }
To copy to clipboard, switch view to plain text mode 
Thats what i got so far from other post
But its not working

If someone could please show me an example of how to go about doing it
or direct me accordingly

Kind Regards