Hi,
I'm writing a simple text editor (rich text with html as engine), so i use the QTextEdit class wich is really great... So far bold, italic, underline, alignments etc... work great.
Now I'm trying to allow subscript and superscript text.
The problem is that it doesn't work:
ui
->htmlTextEdit
->currentCharFormat
().
setVerticalAlignment(QTextCharFormat::AlignSubScript);
ui->htmlTextEdit->currentCharFormat().setVerticalAlignment(QTextCharFormat::AlignSubScript);
To copy to clipboard, switch view to plain text mode
Nothing happens... Anyone?
BTW. i also tried with this:
QString selected_text
= ui
->htmlTextEdit
->textCursor
().
selectedText();
ui->htmlTextEdit->textCursor().removeSelectedText();
ui
->htmlTextEdit
->insertHtml
(QString("<sub>%1</sub>").
arg(selected_text
));
QString selected_text = ui->htmlTextEdit->textCursor().selectedText();
ui->htmlTextEdit->textCursor().removeSelectedText();
ui->htmlTextEdit->insertHtml(QString("<sub>%1</sub>").arg(selected_text));
To copy to clipboard, switch view to plain text mode
The last one works, except that i can use it only when text is selected (QTextEdit has selection).
Thanks!
Bookmarks