qtextedit
#include <QTextCursor> #include <QTextCharFormat> void MainWindow::on_pushButton_clicked() { QTextCharFormat fmt = ui->textEdit->currentCharFormat(); fmt.setForeground(QColor ("red")); ui->textEdit->setCurrentCharFormat(fmt); ui->textEdit->insertPlainText("Abc "); QTextCursor c = ui->textEdit->textCursor(); QTextCharFormat f = c.charFormat(); f.setForeground(QColor ("blue")); c.setCharFormat(f); c.insertText("Def "); }
qtextedit.txt · Last modified: 2018/02/26 16:21 by 127.0.0.1