Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. In Pyside how to is there a signal when focus is changed from QLineEdit to another element
QtWS25 Last Chance

In Pyside how to is there a signal when focus is changed from QLineEdit to another element

Scheduled Pinned Locked Moved Solved Qt for Python
2 Posts 2 Posters 1.6k 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.
  • K Offline
    K Offline
    kumar80
    wrote on last edited by
    #1

    I have a QLineEdit element on tabbing or clicking on some other element the focus is changed to next element. Is there a signal for QLineEdit so that when focus is moved away from the element a signal is sent?

    currently there is only for returnPressed
    self.MyQLineEdit.returnPressed.connect(
    self.checkExistingWeight)

    I am looking for something like this.
    self.MyQLineEdit.focusChanged.connect(
    self.checkExistingWeight)

    eyllanescE 1 Reply Last reply
    0
    • K kumar80

      I have a QLineEdit element on tabbing or clicking on some other element the focus is changed to next element. Is there a signal for QLineEdit so that when focus is moved away from the element a signal is sent?

      currently there is only for returnPressed
      self.MyQLineEdit.returnPressed.connect(
      self.checkExistingWeight)

      I am looking for something like this.
      self.MyQLineEdit.focusChanged.connect(
      self.checkExistingWeight)

      eyllanescE Offline
      eyllanescE Offline
      eyllanesc
      wrote on last edited by eyllanesc
      #2

      @kumar80 Use the focusChanged signal from QApplication: https://doc.qt.io/qt-5/qapplication.html#focusChanged

           QApplication.instance().focusChanged.connect(self.handle_focus_changed)
      
      def handle_focus_changed(self, old_widget, now_widget):
          if self.MyQLineEdit is old_widget:
              print("MyQLineEdit lost focus")

      If you want me to help you develop some work then you can write to my email: e.yllanescucho@gmal.com.

      1 Reply Last reply
      2

      • Login

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