Model-view is a software application design paradigm that implements separation of concerns. It is based on the venerable Model-View-Controller (MVC) pattern but differs in that the controller and view are combined into one component.
In model-view design, the model is the component that holds the application data and contains the logic for retrieving, storing, and manipulating data. The view component presents the data to the user and provides an interface for entering and manipulating data. By separating these components of the application, we keep their interdependency to a minimum, making them much easier to reuse or refactor.
Let's go through a simple example to illustrate this process. Starting with the application template from Chapter 4, Building Applications with QMainWindow, let's build a simple text-file editor:
# This code...