Qt World Summit: Submit your Presentation

Copying PNG with alpha channel to the clipboard is not working on windows. How can I fix this?

  • This is my code.

    QImage image= ToTransparent(xxx); //result is transparent image, don't mind this.
    QByteArray imageArray;
    QBuffer buffer(&imageArray);
    image.save(&buffer, "png", 100);
    QMimeData* mimedata = new QMimeData();
    mimedata->setData("png", imageArray);

    On windows, when I use qApp->clipboard()->setMimeData(mimedata);, It can be copied to a few applications like Microsoft Office programs but it doesn't work everywhere like Paint, Photoshop, or whatever.
    And I tried to use qApp->clipboard()->setImage(image); and it works everywhere but It loses transparency and the image is always opaque.

    So I was tried to copy the PNG data to the clipboard using Native Libraries of User32.dll or Kernel32.dll but no luck so far.
    Is there any way I can do this with Qt or Native Library on windows?