In this article we will see how we can implement the key press event for the QCalendarWidget. In order to set the key press event we have to override the keyPressEvent method, by overriding the key press event we can add functions to the calendar whenever the key is pressed.
1. Create a main window
2. Create a QCalendarWidget
3. Set various properties to the calendar
4. Override the keyPressEvent
5. Inside the override method check if the escape key pressed then show the today in calendar
Below is the implementation
Calendar Show Today Calendar Show Today Calendar Show Today Calendar Show Today
Whenever the escape key is pressed it shows the today(present date page)
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.