Adding the drag functionality to the toolbar labels
Reimplementing event handlers
Now that we have some understanding of Events and MIME types we will look at how to implement an event handler in our
More correctly, we are actually reimplementing the event handlers in our class.
Why is this? Basically, they already exist in a parent class but are set to do nothing. Therefore, we must reimplement them in our class (polymorphism again) with the actions we choose.
Adding the 'drag'
To add drag and drop functionality between the toolbar labels and the graphical field representation we need to answer our investigation list question:
- How do we create draggable icons?
On the previous page we were advised that we will need to reimplement the **
mouseMoveEvent method to add this functionality to our toolbar labels.
The video below demonstrates how to do this.
Use the above video to the ability to drag icons off of the toolbar.
- 1. Installing PyQt on Mac OS X
- 2. Installing PyQt on Windows
- 3. Introduction to PyQt
- 4. Graphical crop simulation
- 5. Creating a basic PyQt application
- 6. Introduction to Layouts
- 7. Radio Button Widget
- 8. Creating the layouts
- 9. Switching layouts
- 10. Adding growth functionality
- 11. Graphics and resources
- 12. Summary
- 13. Field simulation
- 14. Designing the user interface
- 15. Graphical representation of crops and animals
- 16. Resources file
- 17. Crop and animal graphical sub-classes
- 18. Graphical representation of the field
- 19. Toolbars
- 20. Introduction to event handling
- 21. Adding the drag functionality to the toolbar labels
- 22. Adding the 'drop' functionality to the field
- 23. Context Menus
- 24. Automatically growing the field
- 25. Manually growing the field
- 26. Field Report
- 27. Final Summary
- 28. Distributing your application
- 29. Distributing your application on Mac OS X
- 30. Distributing your application on Windows