[Solved]Change text cursor color in QTextEdit
-
yes, i think that if change the text color, then the text cursor obviously should change color too. But that doesn't happen.
so I have black background, and I have changed the text color to white, BUT the cursor color doesn't change to the same color as the text and is therefore invisible. Which is why asked if it is explictly possible to change the cursor color.
to clarify, here is my desired setup:
black background, white text, white cursor.and what actually happens after changing the colors:
black background, white text, black cursor. -
!http://img546.imageshack.us/img546/296/mainwindowr.png(Text Edit with White Color and Text Cursor with White Color )!
-
Here is the code I used to change the colors:
@QPalette p = textEdit->palette();
p.setColor(QPalette::Base, QColor(0, 0, 0));
textEdit->setPalette(p);textEdit->setFrameShape(QFrame::NoFrame);
textEdit->setTextColor(QColor(255,255,255));
@
If I use a style sheet, is it possible to change the colors on the run too? The background color won't change but text color might. -
Thanks Riz and Aleksey, it works now, using this
@
textEdit->setStyleSheet(
"QTextEdit"
"{"
"color: white;"
"background-color: black;"
"}"
);@So the cursor color can be set by setting color: whatever in a stylesheet.. But apparently not with setTextColor() or any other function of textEdit.. weird, but I'm glad it works now.