{\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf13 0
{\fonttbl\f0\fswiss\fcharset0 Helvetica;\f1\fswiss\fcharset0 ArialMT;\f2\fnil\fcharset0 LucidaGrande;
}
{\colortbl;\red255\green255\blue255;\red0\green0\b lue255;}
\paperw11900\paperh16840\vieww12000\viewh15840\vie wkind0
\deftab720
\pard\pardeftab720\partightenfactor0

\f0\b\fs28 \cf0 License Agreement
\f1 \'96 Term of Use
\b0\fs22 \
\

}
The above is the rtf text example.
How can i show rtf file in QTextEdit in qt?
Can I use QClipboard to convert the text to html and paste it in the QTextEdit like the following code? Thank you very much.

Qt Code:
  1. QString filename="/home/clement/test.rtf";
  2.  
  3. QFile file(filename);
  4. if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
  5. ui->textEdit->setPlainText(file.readAll());
  6. }
  7. file.close();
  8.  
  9. QTextDocument *document = ui->textEdit->document();
  10.  
  11. QClipboard *board = QApplication::clipboard();
  12. QMimeData *mimeData = new QMimeData();
  13. mimeData->setText(document->toPlainText());
  14. board->setMimeData(mimeData, QClipboard::Clipboard);
  15.  
  16. QString str = board->text();
  17. QMessageBox::information(NULL, tr("剪貼簿內容"), str);
To copy to clipboard, switch view to plain text mode