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. Hiding the cursor on QLineEdit

Hiding the cursor on QLineEdit

Scheduled Pinned Locked Moved Solved General and Desktop
9 Posts 4 Posters 882 Views
  • 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.
  • J Offline
    J Offline
    Jonikles
    wrote on last edited by
    #1

    Pretty much the title. I have a QLineEdit and I want whenever the user clicks away on something else to stop the focus on the QLineEdit. If that's not possible then if you guys have any idea on how to completely remove the cursor in the first place that would also work.
    Thanks!

    JonBJ 1 Reply Last reply
    0
    • J Jonikles

      @Pl45m4 oh yeah whenever I click on a different widget it disappears that's a brain fart on my end haha. But it doesn't work when clicking on a QFrame.. any way to change that?
      BTW, if it helps in general:
      Windows 10, QT 6.5, default QLineEdit.

      M Offline
      M Offline
      mpergand
      wrote on last edited by
      #8

      @Jonikles said in Hiding the cursor on QLineEdit:

      But it doesn't work when clicking on a QFrame.. any way to change that?

      call :
      QFrame::setFocusPolicy(Qt::ClickFocus)

      J 1 Reply Last reply
      3
      • J Jonikles

        Pretty much the title. I have a QLineEdit and I want whenever the user clicks away on something else to stop the focus on the QLineEdit. If that's not possible then if you guys have any idea on how to completely remove the cursor in the first place that would also work.
        Thanks!

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #2

        @Jonikles said in Hiding the cursor on QLineEdit:

        I have a QLineEdit and I want whenever the user clicks away on something else to stop the focus on the QLineEdit.

        When you "click away to something else" that should remove the focus on the QLineEdit, and stop showing the cursor.

        J Pl45m4P 2 Replies Last reply
        1
        • JonBJ JonB

          @Jonikles said in Hiding the cursor on QLineEdit:

          I have a QLineEdit and I want whenever the user clicks away on something else to stop the focus on the QLineEdit.

          When you "click away to something else" that should remove the focus on the QLineEdit, and stop showing the cursor.

          J Offline
          J Offline
          Jonikles
          wrote on last edited by Jonikles
          #3

          @JonB like automatically? if that's what you're saying then that is not what's happening for me. It's like this:
          Until you start editing - no focus obviously, but once you do it never goes away unless I focus onto a different QEditLine but that's no solution.

          M 1 Reply Last reply
          0
          • J Jonikles

            @JonB like automatically? if that's what you're saying then that is not what's happening for me. It's like this:
            Until you start editing - no focus obviously, but once you do it never goes away unless I focus onto a different QEditLine but that's no solution.

            M Offline
            M Offline
            mpergand
            wrote on last edited by
            #4

            @Jonikles
            Implement an event filter on the parent window then,
            when a click occurred on an other button, call clearFocus() on your line edit.

            1 Reply Last reply
            3
            • JonBJ JonB

              @Jonikles said in Hiding the cursor on QLineEdit:

              I have a QLineEdit and I want whenever the user clicks away on something else to stop the focus on the QLineEdit.

              When you "click away to something else" that should remove the focus on the QLineEdit, and stop showing the cursor.

              Pl45m4P Offline
              Pl45m4P Offline
              Pl45m4
              wrote on last edited by Pl45m4
              #5

              @JonB said in Hiding the cursor on QLineEdit:

              When you "click away to something else" that should remove the focus on the QLineEdit, and stop showing the cursor.

              Depends on what/where clicking elsewhere is, I guess.

              If you ( @Jonikles ) click/focus another widget or window, the cursor should definitely disappear.
              Can you confirm that?!

              What OS are you on? Which Qt version? Are we dealing with a default QLineEdit or any re-implementation or subclass?

              But this sounds so weird, that it is too obvious to be a bug that stayed in for a longer time, no matter what Qt version.


              If debugging is the process of removing software bugs, then programming must be the process of putting them in.

              ~E. W. Dijkstra

              J 1 Reply Last reply
              0
              • Pl45m4P Pl45m4

                @JonB said in Hiding the cursor on QLineEdit:

                When you "click away to something else" that should remove the focus on the QLineEdit, and stop showing the cursor.

                Depends on what/where clicking elsewhere is, I guess.

                If you ( @Jonikles ) click/focus another widget or window, the cursor should definitely disappear.
                Can you confirm that?!

                What OS are you on? Which Qt version? Are we dealing with a default QLineEdit or any re-implementation or subclass?

                But this sounds so weird, that it is too obvious to be a bug that stayed in for a longer time, no matter what Qt version.

                J Offline
                J Offline
                Jonikles
                wrote on last edited by
                #6

                @Pl45m4 oh yeah whenever I click on a different widget it disappears that's a brain fart on my end haha. But it doesn't work when clicking on a QFrame.. any way to change that?
                BTW, if it helps in general:
                Windows 10, QT 6.5, default QLineEdit.

                Pl45m4P M 2 Replies Last reply
                0
                • J Jonikles

                  @Pl45m4 oh yeah whenever I click on a different widget it disappears that's a brain fart on my end haha. But it doesn't work when clicking on a QFrame.. any way to change that?
                  BTW, if it helps in general:
                  Windows 10, QT 6.5, default QLineEdit.

                  Pl45m4P Offline
                  Pl45m4P Offline
                  Pl45m4
                  wrote on last edited by Pl45m4
                  #7

                  @Jonikles said in Hiding the cursor on QLineEdit:

                  But it doesn't work when clicking on a QFrame

                  Clicking on a QFrame or plain QWidget doesn't direct the focus to them per default. It triggers MouseClick / -ReleaseEvents, but the focus stays at QLineEdit, therefore the cursor is staying visible. Same for any other widget, where you can select something. Selected QListWidgetItems stay selected, when clicking somewhere on an empty QWidget space (QFrame is also a QWidget).

                  To work around that, try what @mpergand suggested. Install an eventFilter and move the focus where you want it to be, when your QLineEdit has focus and your QFrame is clicked.

                  [Edit: @mpergand 's new solution works even better ;-) ]


                  If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                  ~E. W. Dijkstra

                  1 Reply Last reply
                  1
                  • J Jonikles

                    @Pl45m4 oh yeah whenever I click on a different widget it disappears that's a brain fart on my end haha. But it doesn't work when clicking on a QFrame.. any way to change that?
                    BTW, if it helps in general:
                    Windows 10, QT 6.5, default QLineEdit.

                    M Offline
                    M Offline
                    mpergand
                    wrote on last edited by
                    #8

                    @Jonikles said in Hiding the cursor on QLineEdit:

                    But it doesn't work when clicking on a QFrame.. any way to change that?

                    call :
                    QFrame::setFocusPolicy(Qt::ClickFocus)

                    J 1 Reply Last reply
                    3
                    • M mpergand

                      @Jonikles said in Hiding the cursor on QLineEdit:

                      But it doesn't work when clicking on a QFrame.. any way to change that?

                      call :
                      QFrame::setFocusPolicy(Qt::ClickFocus)

                      J Offline
                      J Offline
                      Jonikles
                      wrote on last edited by
                      #9

                      @mpergand @Pl45m4 amazing! thank you both :D

                      1 Reply Last reply
                      0
                      • J Jonikles has marked this topic as solved on
                      • J Jonikles has marked this topic as unsolved on
                      • J Jonikles has marked this topic as solved on

                      • Login

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