[Qt-interest] QClipboard with jpeg files, question
Harri Pasanen
grego at mpaja.com
Sat Jul 23 14:30:50 CEST 2011
Hi,
Using Qt 4.7.3
I tried to put a jpeg to QClipboard in the hope that I could just paste it
from there to email. Unfortunately it doesn't work for me:
The following snippet works fine and seems to put a png to clipboard (on
linux):
QClipboard *clipboard = QApplication::clipboard();
clipboard->setPixmap(pic);
I can the paste this to KMail for instance.
As pngs are big, I figured I would try turning it to jpeg, the code being:
QByteArray ba;
QFile jpgfile(filename);
jpgfile.open(QIODevice::ReadOnly);
ba = jpgfile.readAll();
jpgfile.close();
QMimeData *md = new QMimeData();
QString imgtype = "image/jpeg";
md->setData(imgtype, ba);
QClipboard *clipboard = QApplication::clipboard();
clipboard->setMimeData(md);
(I saved the pixmap as jpeg file to check the jpeg is ok)
But that does not seem to work, I still get a png from clipboard....
It's a bit unclear to me at what level this conversion is done, Qt or OS or
...?
Any hints?
Thanks,
Harri
http://mpaja.com/
More information about the Qt-interest-old
mailing list