Qt Development QLineEdit Cursor Color
-
I'm trying to customize the QLineEdit cursor (the blinking caret), especially its color and thickness. I’ve tried both
QPalette::Text
andQLineEdit { color: xxx; }
in stylesheet, but the cursor remains black regardless of these settings.I’ve confirmed that
QTextEdit
allows customizing cursor color via palette, butQLineEdit
does not respond to that. Even using a dark background, the insertion cursor remains hard to see.I also checked Qt source code and found the cursor is drawn in QWidgetLineControl::draw(), using
p.setPen(pal.text().color())
. However, stylesheet seems to override palette partially.Is there an official or recommended way to override QLineEdit’s caret color? Or is subclassing + reimplementing
paintEvent()
the only way?