Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Force always blinking cursor on QLineEdit
Qt 6.11 is out! See what's new in the release blog

Force always blinking cursor on QLineEdit

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 4 Posters 3.3k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    Omni_Philm
    wrote on last edited by
    #1

    Hello all,

    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?

    1 Reply Last reply
    0
    • Kent-DorfmanK Offline
      Kent-DorfmanK Offline
      Kent-Dorfman
      wrote on last edited by Kent-Dorfman
      #2

      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.

      The dystopian literature that served as a warning in my youth has become an instruction manual in my elder years.

      1 Reply Last reply
      1
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by mrjj
        #3

        Hi
        All the blinking is inside private/header class
        https://code.woboq.org/qt5/qtbase/src/widgets/widgets/qwidgetlinecontrol.cpp.html#_ZN18QWidgetLineControl24setBlinkingCursorEnabledEb

        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?

        1 Reply Last reply
        4
        • D Offline
          D Offline
          deping chen
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved