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. QLineEdit focus Event

QLineEdit focus Event

Scheduled Pinned Locked Moved Solved General and Desktop
9 Posts 4 Posters 3.8k 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.
  • A Offline
    A Offline
    ArunBm
    wrote on last edited by
    #1

    How do I capture QlineEdit Focus
    Anybody Give me Python Code to Capture Focus Event

    jsulmJ 1 Reply Last reply
    0
    • A ArunBm

      How do I capture QlineEdit Focus
      Anybody Give me Python Code to Capture Focus Event

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @ArunBm You can subclass QLineEdit and reimplement https://doc.qt.io/qt-5/qwidget.html#focusInEvent

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2
      • A Offline
        A Offline
        ArunBm
        wrote on last edited by
        #3

        cant be simple like self.btnClose.clicked.connect ( handler) like in case of QPushButton click Handler ?

        J.HilkJ 1 Reply Last reply
        0
        • A ArunBm

          cant be simple like self.btnClose.clicked.connect ( handler) like in case of QPushButton click Handler ?

          J.HilkJ Offline
          J.HilkJ Offline
          J.Hilk
          Moderators
          wrote on last edited by J.Hilk
          #4

          @ArunBm
          sadly a focusIn event is only available for QML objects, not QWidgets


          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Hi,

            No, as @jsulm wrote and as explained in the documentation, you have to re-implement that method in a subclass. Or depending on what you want to do, an event filter might be enough.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • A Offline
              A Offline
              ArunBm
              wrote on last edited by
              #6

              Thanks @jsulm @SGaist
              I found self.txtVillage.installEventFilter(self) which is sufficient for my needs.

              Actually I designed a form using Qt Designer and want to capture OnFocus Event of QlineEdit Widget on Ui File. Is it possible to subclass and use it in Ui ?

              jsulmJ 1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                Do you mean subclass QLineEdit ?

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  ArunBm
                  wrote on last edited by
                  #8

                  yes @SGaist

                  1 Reply Last reply
                  0
                  • A ArunBm

                    Thanks @jsulm @SGaist
                    I found self.txtVillage.installEventFilter(self) which is sufficient for my needs.

                    Actually I designed a form using Qt Designer and want to capture OnFocus Event of QlineEdit Widget on Ui File. Is it possible to subclass and use it in Ui ?

                    jsulmJ Offline
                    jsulmJ Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    @ArunBm said in QLineEdit focus Event:

                    Is it possible to subclass and use it in Ui ?

                    Yes, it is.
                    Subclass it, add normal QLineEdit and then promote your own subclass.
                    https://doc.qt.io/archives/qt-4.8/designer-using-custom-widgets.html

                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    1

                    • Login

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