PDA

View Full Version : How to paste richtext with images to a QTextEdit



jpmgr
23rd May 2014, 11:58
If I paste content from a MS Word doc file( with say 3 images and some text) to a QTextEdit I don't see the images. So, how do I read the clipboard and convert the images to base64 before pasting to the QTextEdit so that I can save the document to a database.

boatless
24th June 2015, 21:53
Any answers to this question ??
I have the same issue. I'm not even sure this is possible. Can an image embedded in a WordPad file be copy and pasted into QTextEdit ? (it also can't seem to go the other way). I have extended the QTextEdit class and can successfully copy and paste png or bmp files from Windows Explorer, which come through as Urls, but when an image is dragged over from Word Pad the formats include "Rich Text Format" and "Embedded Object". Is it even possible to paste these into Qt? My overridden insertFromMimeData, otherwise works pretty well. Is the solution to convert the rtf formatted data to html ? Is there any easy way to extract the embedded images ?
Thanks

anda_skoa
25th June 2015, 09:47
Is it even possible to paste these into Qt?

QMimeData has no restrictions on what the data can be.
The data might need some processing if it is not one of the things the class has convenience API for (images, URIs, text, HTML).



Is the solution to convert the rtf formatted data to html ?


That might be an option. Windows might even have some facility to convert RTF into HTML.



Is there any easy way to extract the embedded images ?

You'll probably need to search MSDN for that, it is not unlikely that Microsoft has tools/libraries for that.

Cheers,
_