Drag and drop
In this section, we will learn about drag and drop (DnD). In a GUI application, DnD is a pointing device gesture in which the user selects a virtual object by grabbing it and then releasing it on another virtual object. The drag and drop operation starts when the user makes some gesture that is recognized as a signal to start a drag action.
Let's discuss how we can implement drag and drop using Qt Widgets.
Drag and drop in Qt Widgets
In Qt Widgets-based GUI applications, where drag and drop is used, the user starts dragging from a particular widget and drops the dragged object onto another widget. This requires us to reimplement several functions and it handles the corresponding events. The most common functions that need to be reimplemented to achieve drag and drop are as follows:
void dragEnterEvent(QDragEnterEvent *event) override; void dragMoveEvent(QDragMoveEvent *event) override; void dropEvent(QDropEvent *event) override; void mousePressEvent(QMouseEvent...