How to set the color of caret blinking cursor in QLineEdit? I have a question, which is how to change the color of caret blinking cursor in QLineEdit.
How to set the color of caret blinking cursor in QLineEdit? I have a question, which is how to change the color of caret blinking cursor in QLineEdit.
There is one way you can give a try. Theoretically it looks like it should work (not tested. Look for compile time errors.)
First get the image of icon you want to set.
Then load the image to get QPixmap object.
QPixmap myPixmap;
myPixmap.load("<<YOURIMAGEPATH>>/cursoricon.png");
Now set the color to QPixmap using
https://doc.qt.io/qt-5/qpixmap.html#fill
myPixmap.fill(QColor(0,255,0));
Now create a QCursor object using QPixmap object
https://doc.qt.io/qt-5/qcursor.html#QCursor-3
QCursor cursor = QCursor(myPixmap);
Then set the cursor to your line edit object.
pLineEdit->setCursor(cursor);
Actually the setCursor function, first I thought it works only for mouse cursor. But the documentation says it holds good for editor widgets also. https://doc.qt.io/qt-5/qwidget.html#cursor-prop
An editor widget might use an I-beam cursor