Click here to Skip to main content
15,887,175 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I'm getting data from clipboard and checking its type:
const QClipboard *clipboard = QApplication::clipboard();
const QMimeData *mimeData = clipboard->mimeData();

if (mimeData->hasImage()) {
label->setPixmap(qvariant_cast<qpixmap>(mimeData->imageData()));
}
else if (mimeData->hasFormat("text/html")) {
label->setText(mimeData->html());
}
else if (mimeData->hasFormat("text/plain")) {...}
else {
???
}

If its not image or text (last "else" condition), i want to treat it as file.
I want to get QByteArray and write it to file.

So, how can i get raw (QByteArray) data from clipboard?

What I have tried:

I'v tried to get it as mimeData->text(), but it just pointed me to a file path, with output like:
file:///E:/app.exe
file:///E:/note.txt
Posted
Updated 31-Oct-20 21:45pm

1 solution

Try using QMimeData Class | Qt Core 5.15.1[^] to see which formats the data can be returned in.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900