In this article we will see how we can drag and drop the calendar in the main window. In order to drag the calendar user has to click on the title bar of the calendar and move the cursor to move the calendar and in order to drop just release the cursor.
Implementation steps :
1. Create a Calendar class that inherits the QCalendarWidget
2. Inside the Calendar class override the mouse press and release event inside the events update the move flag
3. Create a main window class
4. Create a Calendar object
5. Set main window mouse tracking enabled
6. Override the mouse move event
7. Inside the mouse move event get the x, y co-ordinates and change the position of calendar according to it
Below is the implementation
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.