Remove formatting from a text



  • 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



  • [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()



  • 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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.