Drag and drop

In this section, we shall put together a simple application that can handle drag and drop operations from an external source into an application.

The application is a small text editor. When a text file is dropped into the text area, it will open and insert the contents of that text file into the text area. The status of the window will show the number of characters in the text area, which is an instance of a QTextEdit.

This example application also illustrates a very important point about events. To customize a widget, one has to change the existing behavior of that widget by overriding its event handlers. Signals and slots are not considered when trying to customize widgets (except events).

To begin this project, perform the ...

Get Getting Started with Qt 5 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.