Save a .rtf file formatting the text in a QTextEdit
-
As already told on so you use toPlaintText() and wonder why the formatting is not saved... isn't the function name meaningful enough?
-
As already told on so you use toPlaintText() and wonder why the formatting is not saved... isn't the function name meaningful enough?
@Christian-Ehrlicher alright, but is there a way to get the formatted text?
-
@HenkCoder There is, to some extent. Please see overview under the link below.
-
@artwaw Hey, I read the documentation and I wasn't able to find anything useful to my problem.
@HenkCoder I suggest you read that again maybe?
As documentation states, rich text formatting in Qt is done via HTML subset. So, in case of QTextEdit, you will look at toHtml() method to obtain formatted text.
RTF is closed format, owned by Microsoft, however its specification is available - since Qt lacks direct support my approach would be to implement a model that converts Qt Rich Text to RTF and vice versa https://docs.microsoft.com/en-us/previous-versions/office/developer/office2000/aa140280(v=office.10)?redirectedfrom=MSDN
-
@HenkCoder I suggest you read that again maybe?
As documentation states, rich text formatting in Qt is done via HTML subset. So, in case of QTextEdit, you will look at toHtml() method to obtain formatted text.
RTF is closed format, owned by Microsoft, however its specification is available - since Qt lacks direct support my approach would be to implement a model that converts Qt Rich Text to RTF and vice versa https://docs.microsoft.com/en-us/previous-versions/office/developer/office2000/aa140280(v=office.10)?redirectedfrom=MSDN
-
@artwaw
Oh, I really don't know how to do this, I don't know much about Qt, can someone give me some help?@HenkCoder
Basically you can't, or it's hard. Why do you have to have.RTF
format anyway? Use HTML (Qt's "rich text"). -
@HenkCoder
Basically you can't, or it's hard. Why do you have to have.RTF
format anyway? Use HTML (Qt's "rich text"). -
@JonB because I want to save a file, I can't let the user save an HTML file, he may not understand it
@HenkCoder
RTF is a Microsoft format, effectively. " he may not understand it" --- "he" who/what? It's an "unusual" format to want to save in. Anyway, the answer remains the same. -
@HenkCoder
RTF is a Microsoft format, effectively. " he may not understand it" --- "he" who/what? It's an "unusual" format to want to save in. Anyway, the answer remains the same. -
@HenkCoder oh nevermind, I managed to understand. Thank you for your help.