PDA

View Full Version : QPlainTextEdit Change the QTextCursor caret



ArkKup
19th May 2015, 13:06
Hi, I'd like to change QPlainTextEdit cursor caret to rectangle one. I found a way to do it like this


QPalette pal;
QColor bgColor("black");
QColor fgColor(192, 192, 192);
QColor hiColor("darkGray");
pal.setColor(QPalette::Base, bgColor);
pal.setColor(QPalette::Text, fgColor);
pal.setColor(QPalette::Highlight, hiColor);
pal.setColor(QPalette::HighlightedText, bgColor);
ui->plainTextEdit->setPalette(pal);

QFontMetrics fm(font());
ui->plainTextEdit->setCursorWidth( fm.averageCharWidth() );
qApp->setCursorFlashTime(0);

http://s9.postimg.org/i18x543jf/caret_pic.png (http://postimage.org/)

But how to change the cursor foreground color to make the char visible again ?