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. Remove formatting from a text
Forum Update on Monday, May 27th 2025

Remove formatting from a text

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.2k Views
  • 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.
  • M Offline
    M Offline
    Marty
    wrote on last edited by
    #1

    Hello,

    simple question : is there a way to remove all specific formatting from a text ? Like the button that exists in some wysiwyg editors or in gmail for instance : "remove all formatting" that allows to convert underlined / colored etc... text into plain text.

    my problem : i have a line edit where i want to copy/paste text, and i have some character encoding problems from time to time, like when the copied text is from a web page.

    i already use character conversions like toUtf8() or fromLatin1()

    Thanks

    1 Reply Last reply
    0
    • S Offline
      S Offline
      Seamus Boyle
      wrote on last edited by
      #2

      [quote author="Marty" date="1393353454"]
      my problem : i have a line edit where i want to copy/paste text, and i have some character encoding problems from time to time, like when the copied text is from a web page.
      [/quote]
      QLineEdit has copy/paste built in, nothing more is necessary. If you still want to remove/replace characters, look at methods of QString that take a QRexExp.

      [quote author="Marty" date="1393353454"]
      i already use character conversions like toUtf8() or fromLatin1()
      [/quote]
      Have you tried fromUtf8()

      1 Reply Last reply
      0
      • M Offline
        M Offline
        Marty
        wrote on last edited by
        #3

        Sorry the text i copy is from a webpage and i paste it in a cell of a QTableWidget but i think this doesn't make any difference.

        I grab my text from the web page then i paste it into the cell.
        I read the cell with currentItem()->text()

        i then send this to my server which only understands latin1 character encoding with send(text.toLatin1())

        example :

        when i write manually the word "d'après" in the cell and sends it, my server displays "d'après"

        when i copy/paste the same word from a site, my server displays "d?après"

        Character encoding seems ok, but in the case of copy/paste there seems to be an issue

        1 Reply Last reply
        0

        • Login

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