Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Line break is copied together with selected text in html list

Line break is copied together with selected text in html list

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 1.3k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • X Offline
    X Offline
    xsbolop
    wrote on last edited by
    #1

    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?

    A 1 Reply Last reply
    0
    • X xsbolop

      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?

      A Offline
      A Offline
      ambershark
      wrote on last edited by
      #2

      @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"?

      My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

      1 Reply Last reply
      1
      • X Offline
        X Offline
        xsbolop
        wrote on last edited by
        #3

        Yes, anything you copy it pastes it with \n in front of it

        1 Reply Last reply
        0
        • mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi
          Seems to be related to it copy as html and the text version of it, then contains \n\r
          alt text

          Unless there is an option, i think you need to handle the copy to clipboard your self to prevent this.

          1 Reply Last reply
          2
          • A Offline
            A Offline
            ambershark
            wrote on last edited by
            #5

            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.

            My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

            1 Reply Last reply
            2

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved