I would follow JPN's suggestion, but using QImage::scanLine() like this:
Qt Code:
  1. QImage image(width, height, QImage::Format_Indexed8);
  2. for (int y = 0;y<height; y++)
  3. memcpy(image.scanLine(y), rawData + y*width, width);
To copy to clipboard, switch view to plain text mode 
The problem with QImage::bits() is that Qt might add padding to each row to align the rows to 32 bits.

Then you need to set the Color table like this:
Qt Code:
  1. QVector<QRgb> colorTable(256);
  2. for(int i=0;i<256;i++)
  3. colorTable[i] = qRgb(i,i,i);
  4. image.setColorTable(colorTable);
To copy to clipboard, switch view to plain text mode