Results 1 to 8 of 8

Thread: Hide blinking cursor from QLineEdit

  1. #1
    Join Date
    Aug 2014
    Posts
    11
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Question Hide blinking cursor from QLineEdit

    Hi,

    I need to hide the blinking cursor (caret) of QLineEdit permanently.
    But at the same time, I want the QLineEdit to be editable (so readOnly and setting editable false is not an option for me).

    I am changing the Background color of the QLineEdit, when it is in focus, so I will know which QLineEdit widget is getting edited.
    For my requirement, cursor (the blinking text cursor) display should not be there.

    I have tried styleSheets, but I can't get the cursor hidden ( {setting color:transparent; text-shadow:0px 0px 0px black;} )

    Can someone please let me know how can I achieve this?

    Thanks,
    Ash

  2. #2
    Join Date
    Apr 2012
    Location
    India.
    Posts
    88
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Hide blinking cursor from QLineEdit

    Please see below link about bug reported on qt forum for QLineEdit cursor...

    https://qt.gitorious.org/qt/sroedals...f8ff5b19cb4ffc

    I don't about the version but may be it's related...

  3. #3
    Join Date
    Aug 2014
    Posts
    11
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Hide blinking cursor from QLineEdit

    Thanks for the reply. I also saw that, but that bug report is posted 4 years ago, so I am not sure about its status.

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Hide blinking cursor from QLineEdit

    I need to hide the blinking cursor (caret) of QLineEdit permanently.
    But at the same time, I want the QLineEdit to be editable (so readOnly and setting editable false is not an option for me).
    So, put yourself in the place of the person using your software. They have clicked or tabbed over to the edit box and they want to change something in it. Every other app in the universe shows them a blinking caret cursor that not only indicates that they can edit, but also shows them where in the text they are editing.

    Your implementation won't provide them any feedback at all. Nothing to show them that the control has edit focus, nothing to show them where they are about to make a change. If I were the user, I'd keep trying to click the edit box, because I expect it to react in the same way as every other app I use. Eventually I would give up and file a bug report.

    So why on earth would you want to implement a behavior that is totally different from what users expect?

  5. #5
    Join Date
    Aug 2014
    Posts
    11
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Hide blinking cursor from QLineEdit

    I totally understand your concern.
    But in my requirement, we have a LCD panel of a printer. In these InputBoxes (they are for numeric input only, by using validator), there is no way to press Backspace or move the cursor anywhere without typing a number. But the widget on which the focus is there, is having blue color and the other widgets are white in color. So the end user is aware of the widget where editing is done
    Also, as soon as focus shifts on the widget, the complete value is selected (so, any new entry after focus is obtained, replaces the earlier value). Selected (highlighted) color is same shade of blue as the in-focus widget background color.

    So, basically, as per the design team, cursor is unwanted in these widgets (as end user doesn't have any control over the cursor anyway)

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Hide blinking cursor from QLineEdit

    Quote Originally Posted by ashtray4241 View Post
    I totally understand your concern.
    But in my requirement, we have a LCD panel of a printer. In these InputBoxes (they are for numeric input only, by using validator), there is no way to press Backspace or move the cursor anywhere without typing a number. But the widget on which the focus is there, is having blue color and the other widgets are white in color. So the end user is aware of the widget where editing is done
    Also, as soon as focus shifts on the widget, the complete value is selected (so, any new entry after focus is obtained, replaces the earlier value). Selected (highlighted) color is same shade of blue as the in-focus widget background color.

    So, basically, as per the design team, cursor is unwanted in these widgets (as end user doesn't have any control over the cursor anyway)
    So you mean that if I click on the widget, then enter numbers 1234 and then click between "2" and "3" then the cursor is not moved there and pressing "5" will not result in string "12534" but rather "12345"?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Aug 2014
    Posts
    11
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Hide blinking cursor from QLineEdit

    Quote Originally Posted by wysota View Post
    So you mean that if I click on the widget, then enter numbers 1234 and then click between "2" and "3" then the cursor is not moved there and pressing "5" will not result in string "12534" but rather "12345"?
    Yeah. Cursor doesn't move. We have basically two kind of widgets. One is normal Input box, which accepts all charaters, cursor can be displayed, moved etc and another is a numeric input box, where cursor position cannot be moved. After every focus received event, the new value will replace older value, and while focus is set on the widget, cursor will not be manually moved (it can only move one space at a time when entering the numeric value). So the result in the use case you mentioned will be 12345 only.

    It may not be too user friendly, but the design department has this requirement. Currently we are using PEG where the cursor is not visible. We are porting the device to QT from PEG, and design department wants the same look and feel.

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Hide blinking cursor from QLineEdit

    You can always subclass QLineEdit and reimplement its paint event. You can check the class's source code to see how QLineEdit draws itself, it will probably take you some time but at the end you should be able to identify a call that you can override (e.g. in the style) to get the desired behavior.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Hide cursor of QLineEdit
    By Alundra in forum Qt Programming
    Replies: 7
    Last Post: 3rd June 2014, 14:59
  2. Replies: 6
    Last Post: 10th September 2013, 12:44
  3. Replies: 2
    Last Post: 10th May 2013, 06:20
  4. How to Disable or hide cursor from QWidget?
    By ashukla in forum Qt Programming
    Replies: 5
    Last Post: 17th October 2007, 14:42
  5. How to hide mouse cursor
    By kiransu123 in forum Qt Programming
    Replies: 1
    Last Post: 23rd March 2007, 17:52

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.