Does there exist a better way to do it than this?

Qt Code:
  1. void setAlphaChannel(QPixmap& pixmap, int const alpha)
  2. {
  3. QImage image(pixmap.toImage().convertToFormat(QImage::Format_ARGB32));
  4.  
  5. for (int x(0); x != image.width(); ++x)
  6. {
  7. for (int y(0); y != image.height(); ++y)
  8. {
  9. QColor color(image.pixel(x,y));
  10.  
  11. color.setAlpha(alpha);
  12.  
  13. image.setPixel(x, y, color.rgba());
  14. }
  15. }
  16.  
  17. pixmap = QPixmap::fromImage(image);
  18. }
To copy to clipboard, switch view to plain text mode 

I've read about the now-obsolete QPixmap method called setAlphaChannel(), but it's implementations are platform-dependent.