PyQt5 QCalendarWidget – Checking if its has focus or not
In this article we will see how we can check if the QCalendarWidget has focus or not. Focus is basically the input focus, by default it don’t have focus but when app get executed mouse clicked on it, it get the focus but when mouse click on other widget its focus will get shifted.
In order to do this we will use hasFocus method with the QCalendarWidget object.
Syntax : calendar.hasFocus()
Argument : It takes no argument
Return : It return bool
Implementation Steps :
1. Create a main window
2. Create a Calendar widget
3. Create a line edit widget at different position
4. Create a label to show the focus status
5. Create QTimer object that call the action after every 200 milliseconds
6. Inside the timer action check for the calendar focus
Below is the implementation