RTF
-
How do I copy rtf text (ctrl + c) and paste it into a QTextEdit widget in run time while preserving the rich text format? Btw, this works in QDialog until I save it to a QStringList and retrieve it which converts it to plain text. Also, is it possible for a Qt programmer to incorporate the rtf editor available in QtCreator into his/her own apps?
-
@Charlie2406 said in RTF:
Btw, this works in QDialog until I save it to a QStringList and retrieve it which converts it to plain text
Of course, you cant save rich text in a plain
QString
.Also, is it possible for a Qt programmer to incorporate the rtf editor available in QtCreator into his/her own apps?
Look at the QtCreator source how it's done there and feel free to built your own :)
This might also be helpful:
-
@Charlie2406 Welcome to the Qt forums
I assume you mean text with a format applied and not RTF. There is no RTF support in Qt that I am aware of.
The QTextEdit will accept some rich text if the QTextEdit::acceptRichText() property is true (the default). In this case, the clipboard would need the clipboard MIME data to include either an HTML component, a rich text copy from another Qt program (application/x-qrichtext or application/x-qt-richtext), or possibly Markdown (text/markdown).
You can QTextEdit::canInsertFromMimeData() and QTextEdit::insertFromMimeData() to cater for anything you need to paste.
-
https://doc.qt.io/qt-6/richtext.html
https://doc.qt.io/qt-6/richtext-structure.htmlThanks for the help. I will check out the web sites and source code tomorrow.