here is the code i ended up with:

Qt Code:
  1. uint iWidth = 640;
  2. uint iHeight = 480;
  3. uint iSize = iWidth * iHeight;
  4. uchar *imgData = new uchar[iSize*4];
  5. uint j=0;
  6. for(uint i=0; i<iSize; i++)
  7. {
  8. imgData[j] = 255; // R
  9. imgData[j+1] = 128; // G
  10. imgData[j+2] = 128; // B
  11. imgData[j+3] = 255; // A
  12. j += 4;
  13. }
  14. QImage image(iWidth, iHeight, QImage::Format_ARGB32);
  15.  
  16. for (unsigned int y = 0; y < iHeight; y++)
  17. {
  18. for(unsigned int x = 0; x < iWidth; x++)
  19. {
  20. int s = y*iWidth + x*4;
  21. QColor color(imgData[s], imgData[s+1], imgData[s+2], imgData[s+3]);
  22. image.setPixel(x, y, color.rgba());
  23. }
  24. }
  25.  
  26. m_pm = new QPixmap();
  27. *m_pm = m_pm->fromImage(image);
To copy to clipboard, switch view to plain text mode 

It works as expected. I'm not sure though if everything is done correctly. Please comment on the above code

thanks