Line break is copied together with selected text in html list
-
Hello,
I wrote the following code:
QTextEdit *te = new QTextEdit();
te->setHtml("<ul><li>LINE 1</li><li>LINE 2</li><li>LINE 3</li></ul>);
and I get the following result at TextEdit:- LINE 1
- LINE 2
- LINE 3
If I copy the letter "E" for example, and paste it to a simple editor, it pastes a line break and then the letter "E". If text is outside html list it is copied without line break.
Any ideas how to get rid of line break? -
@xsbolop said in Line break is copied together with selected text in html list:
Hello,
I wrote the following code:
QTextEdit *te = new QTextEdit();
te->setHtml("<ul><li>LINE 1</li><li>LINE 2</li><li>LINE 3</li></ul>);
and I get the following result at TextEdit:- LINE 1
- LINE 2
- LINE 3
If I copy the letter "E" for example, and paste it to a simple editor, it pastes a line break and then the letter "E". If text is outside html list it is copied without line break.
Any ideas how to get rid of line break?So if you copy 'E' from 'LINE 1' you would actually get "\nE" or "E\n"?
-
Hi
Seems to be related to it copy as html and the text version of it, then contains \n\r
Unless there is an option, i think you need to handle the copy to clipboard your self to prevent this.
-
A lot of html controls in applications have a "copy as plain text" option probably for reasons like this.
I would just implement a copy as plain text function yourself as @mrjj suggests.
Should be super easy as you can get the plain text from the control, then just put that on the clipboard in response to a copy instead of the html.