[Qt-interest] QClipboard: copy from Qt into Gimp (on Windows)?
Oliver.Knoll at comit.ch
Oliver.Knoll at comit.ch
Mon Dec 27 15:11:05 CET 2010
Hello,
another question which came up while experimenting with QClipboard: how do I need to setup the MIME data such that I can paste it into The GIMP (http://www.gimp.org) on Windows?
Copy paste from OpenOffice Draw into GIMP works, also when I copy an image in Firefox and paste into GIMP, all well.
I tried both
QImage image = ...;
QMimeData *mimeData = new QMimeData();
mimeData->setImage(image);
and
QByteArray data;
QBuffer buffer(&data);
buffer.open(QIODevice::WriteOnly);
image.save(&buffer, "PNG");
buffer.close();
mimeData->setData("image/png", data);
but to no avail: GIMP always tells me that "there is no data for pasting" (note that copy/paste into e.g. OpenOffice Draw /does/ work, except the alpha channel).
Copy/paste from e.g. OpenOffice Draw into my Qt application works, I get the expected image data. Printing out the received MIME types upon paste:
const QMimeData *mimeData = clipboard->mimeData();
foreach(QString format, mimeData->formats()) {
qDebug("%s", qPrintable(format));
}
Result:
application/x-qt-windows-mime;value="Star Object Descriptor (XML)"
application/x-qt-windows-mime;value="Drawing Format"
application/x-qt-windows-mime;value="SVXB (StarView Bitmap/Animation)"
application/x-qt-image
application/x-qt-windows-mime;value="Windows Bitmap"
application/x-qt-windows-mime;value="GDIMetaFile"
So instead of saving to "PNG" I saved to "BMP" and set the MIME to "image/bmp", no difference: nothing would be pasted into the other application.
So how would I encode my image as e.g. "GDIMetaFile"? What would be the corresponding MIME type? Do I have to register this with e.g. http://doc.trolltech.com/4.7/qmetatype.html#qRegisterMetaType ?
Thanks, Oliver
--
Oliver Knoll
Dipl. Informatik-Ing. ETH
COMIT AG - ++41 79 520 95 22
More information about the Qt-interest-old
mailing list