PDA

View Full Version : Copy a custom image to clip board



dan3460
13th September 2017, 17:51
I have the following code on my program, when the button is clicked it supposed to copy the document on the clipboard, but does nothing. Am i missing something to make this work?


void DocumentQueue::on_clipboard_clicked()
{
QMimeData *pdfDocument = new QMimeData();
pdfDocument->setData("application/pdf",mDocImage);

QClipboard *comOperClipBoard= QApplication::clipboard();
comOperClipBoard->setMimeData(pdfDocument);
}


Just for the heck of it i changed the "application/pdf" for "text/plain" and the document is copied to the clipboard (is just garbage when pasted) so this tells me that the problem has to be with the declaration of Mime object or the way that is passed to the clipboard.