View Full Version : QTextEdit line background color
wirasto
7th April 2015, 09:09
How to set background color for line (not text) in QTextEditor.
Example, every line start with text "DEPRECATED" will set background color red.
use QTextCharFormat only fill background for text :(
wysota
7th April 2015, 09:47
QTextEdit::setExtraSelections()
wirasto
7th April 2015, 11:01
But, why the background color remove when I move cursor??
appendPlainText(QString("TAHEDE %1 ").arg(text));
moveCursor(QTextCursor::End);
moveCursor(QTextCursor::StartOfLine);
QTextEdit::ExtraSelection h;
h.cursor = textCursor();
h.format.setProperty(QTextFormat::FullWidthSelecti on, true);
h.format.setBackground(Qt::green);
QList<QTextEdit::ExtraSelection> extras;
extras << h;
setExtraSelections(extras);
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.