1

How to change the background colour of the line where text cursor (caret) is, using QSyntaxHighlighter and QTextEdit

yolo
  • 2,757
  • 6
  • 36
  • 65

1 Answers1

1

One way i found was using QTextEdit

QTextEdit *textEdit = centralWidget()->findChild<QTextEdit *>("textEdit");

QTextCursor textCursor(textEdit->document());
textCursor.select(QTextCursor::LineUnderCursor);

textEdit->setAutoFillBackground(true);
QPalette palette;
palette.setColor(QPalette::Background,QColor(200,200,200));
textEdit->setPalette(palette);

See if you find this usefull

megha
  • 170
  • 2
  • 10