Save given QImage directly into QByteArray:

Qt Code:
  1. QImage image;
  2. QBuffer buffer(&ba);
  3. buffer.open(QIODevice::WriteOnly);
  4. image.save(&buffer, "PNG");
To copy to clipboard, switch view to plain text mode 
(Taken from Documentation)