{\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.
QString filename
="/home/clement/test.rtf";
ui->textEdit->setPlainText(file.readAll());
}
file.close();
mimeData->setText(document->toPlainText());
board
->setMimeData
(mimeData,
QClipboard::Clipboard);
QMessageBox::information(NULL, tr
("剪貼簿內容"), str
);
QString filename="/home/clement/test.rtf";
QFile file(filename);
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
ui->textEdit->setPlainText(file.readAll());
}
file.close();
QTextDocument *document = ui->textEdit->document();
QClipboard *board = QApplication::clipboard();
QMimeData *mimeData = new QMimeData();
mimeData->setText(document->toPlainText());
board->setMimeData(mimeData, QClipboard::Clipboard);
QString str = board->text();
QMessageBox::information(NULL, tr("剪貼簿內容"), str);
To copy to clipboard, switch view to plain text mode
Bookmarks