Prevent QPlainTextEdit from copying HTML to clipboard?
I need to copy columnar data from a QPlainTextEdit to the clipboard. Since this data will be pasted into spreadsheet programs like Microsoft Excel, I would like to prevent an HTML version going to the clipboard, only plain text. Is there any way to do that? Am I not using the right widget?
Thanks for any suggestions
I would subclass the QPlainTextEdit and override its copy method by formatting the selected text accordingly and then copy it to the clipboard with QApplication::clipboard()->setText(). Also have a look at QClipboard.
I have subclasses QPlainTextEdit and overridden copy(). Had to replace unicode paragraph separators with newlines.
My only issue now is that apparently the key board shortcut for copy (cntrl-C or command-C) doesn't actually call the copy() method.
Any clues on an easy way to intercept/override that one key stroke?
Could you provide a small example and how you implemented the copy method?
Edit: Just tried to do it on my own. Sry, forgot to mention, in order to use your new method you also have to implement the keyPressEvent, something like this:
@void CLASS::keyPressEvent(QKeyEvent *e)