[Qt-interest] QTextEdit line color
RZ
rz at razfazz.at
Wed Feb 11 00:08:15 CET 2009
Answering myself and raising another question:
QTextCursor tc(m_TextBlock);
QTextBlockFormat blockFormat = m_TextBlock.blockFormat();
blockFormat.setForeground(Qt::green); <-- this does not work
blockFormat.setBackground(Qt::red); <-- this works
tc.setBlockFormat(blockFormat);
> Hi all,
>
> I got a QTextEdit where the user can insert several lines; each line is
> a kind of "command". These commands get processed one after the other.
> What i want to achieve is that each line changes its color after
> "execution".
> First intent was to use QSyntaxHighlighter - but this works on the text
> of each line. Not usable for me as the text doesn't change after execution.
> My next idea was to iterate over all the QTextBlock's
> (textEdit->document().begin() and callin next()). For each block I can
> get the QTextBlockFormat and can change the foreground of the
> QTextBlockFormat via setForeground(). _But_ there is no way to set a
> QTextBlockFormat to the QTextBlock.
>
> So I'd appreciate any help.
>
> Thx,
>
> RZ
More information about the Qt-interest-old
mailing list