PDA

View Full Version : QTextEdit copy and paste into email.



chris_helloworld
16th November 2010, 07:49
Hi,
I'm finding that when I copy text from a QTextEdit and paste into an email, (ms outlook), I'm loosing spaces and line feeds. I believe that this is becase the transfer is being done as html. (It works fine if the email format is plain text).

Is there any way to tell the QTextEdit to only put plain text into the mimedata and not html on copy ? Annoyingly, the QTextEdit::copy function is not virtual so I can't simply override it and write my own.

Chris.

tbscope
16th November 2010, 07:54
Knowing Microsoft tools, they never ever paste text as normal text, it's almost always rich text.

Outlook also might expect \r\n line endings.

wysota
16th November 2010, 08:00
Actually any slot when called as a slot acts as it was virtual so you can subclass QTextEdit, redeclare the copy slot and reimplement it. The only trick is that your implementation will only be called when copy() is called as a result of a signal and not a direct function call. But there is a much better option at your disposal - reimplement QTextEdit::createMimeDataFromSelection().

chris_helloworld
16th November 2010, 08:17
Thanks guys :)