Force always blinking cursor on QLineEdit
Omni_Philm last edited by
I have a QLineEdit object on my forum where I want the cursor to always be blinking. I have been searching on the internet to see if others have done this before but it would seem that most people what to hide the cursor. I would like to always display the cursor.
My first solution was to set the line edit to always have focus. If an action removed focus from the line edit, I would always reset the focus back to the QLineEdit. This worked until I realized that when I am tabbing through my form, my tab focus gets reset after a perform an action.
I am pretty sure that I will need a subclass for the line edit. Not a problem since I already created a subclass of the line edit class that emits a mouse click signal.
I also know that i will be modifying the paint event but I am not sure which properties I need to edit. Does any have any thoughts on the matter?
Kent-Dorfman last edited by Kent-Dorfman
I think it's more complicated than subclassing QLineEdit. To implement a custom cursor or custom cursor behaviour I'm guessing you will need to write your own QLineEdit replacement since their is no abstract parent class for QLineEdit.
All the blinking is inside private/header class
so i would try to extra the logic/code and make a thin
wrapper around QLineEdit and override paintEvent and use
the extracted code to let it blink when not having focus.
That said, you are aware is highly uncommon for any platform to show
a blinking cursor in all visible edits?
deping chen last edited by
I want to show cursor in QLineEdit anyway too. My application is like AutoCAD, A graph window with a command line.
When the graph window got the focus, it can send point at clicking and send F1-F12 event to command handler. User keyboard event will be forwarded to QLineEdit after filtering just like the QLineEdit is focused.