The focusWidget() method of the QApplication class returns a reference to the object that is in focus. When you start the program in an object ( QLineEdit ), the cursor flashes and you can enter data, that is, as far as I understand, the object is in focus. Why then app.focusWidget() returns None ?
import sys from PyQt5.QtWidgets import (QWidget, QLineEdit, QApplication) class Example(QWidget): def __init__(self): super().__init__() self.initUI() def initUI(self): qle = QLineEdit(self) qle.move(60, 100) print("app.focusWidget(): ", app.focusWidget()) self.setGeometry(300, 300, 280, 170) if __name__ == '__main__': app = QApplication(sys.argv) ex = Example() ex.show() sys.exit(app.exec_())