Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Copying PNG with alpha channel to the clipboard is not working on windows. How can I fix this?
derekleesoft last edited by derekleesoft
This is my code.
QImage image= ToTransparent(xxx); //result is transparent image, don't mind this. QByteArray imageArray; QBuffer buffer(&imageArray); buffer.open(QIODevice::WriteOnly); image.save(&buffer, "png", 100); buffer.close(); QMimeData* mimedata = new QMimeData(); mimedata->setData("png", imageArray); qApp->clipboard()->setMimeData(mimedata);
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?