giowck
11th February 2011, 10:51
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(QTextChar Format::AlignSubScript);
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));
The last one works, except that i can use it only when text is selected (QTextEdit has selection).
Thanks! ;)
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(QTextChar Format::AlignSubScript);
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));
The last one works, except that i can use it only when text is selected (QTextEdit has selection).
Thanks! ;)