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 QDragLabel sub-classes:

  • WheatDragLabel
  • PotatoDragLabel
  • CowDragLabel
  • SheepDragLabel

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.

Task 7a

Use the above video to the ability to drag icons off of the toolbar.