Sign up for the KDAB Newsletter
Stay on top of the latest news, publications, events and more.
Go to Sign-up
Find what you need - explore our website and developer resources
22 January 2021
0:00 Intro to Workshop
3:25 Beginning of Workshop
9:50 Model/View in Qt: Basic Concepts
25:28 Model Structure
48:02 QAbstractItemModel API
1:08:35 Creating a List Model
1:48:25 Handling Modifications
2:02:25 Going further (bonus slides)
This workshop by KDAB's Giuseppe D'Angelo was presented at QtDay Italy 20. QtDay gathers Qt experts from all over the world and is entirely focused on Qt and Qt-related technologies. The event is organized by Develer.
https://qtday.it/
https://www.develer.com/en/
In 2020, let’s go “back to basics”. Writing model/view code is somehow given for granted. It’s however a mandatory skill for any proficient Qt developer: professionals are supposed to be able to write robust, fast, tested models. We’ll see how together in this workshop.
Any non-trivial Qt application will feature usages of the model/view/controller framework. MVC is a well known design pattern, embracing separation of concerns between managing the data and the user interface that is supposed to visualize and manipulate it.
In this workshop I will focus on the “model” aspect of the MVC framework; that is, the part that interacts directly with the data. Models play a central role in Qt, no matter what’s the UI stack used with of them (Qt Widgets, Qt Quick, remote objects, …). Whilst it’s very rare to develop custom views, it’s instead very very typical for Qt developers to develop custom models; in my professional experience I must have developed hundreds of them.
So, what is exactly a model in Qt’s MVC design? How do we write one? What is the developer’s responsibility, and what instead is provided by Qt, maybe as convenience? What are the performance characteristics of models? And how do we test one? The answers are not so trivial, and it’s important to nail them down to write robust model code that will drive the rest of our user interface.
In this workshop we will write together some models, use them in combination with some views, and while doing so, show all the best practices associated with such development. In a few places we are going to use some classes or functions that I have contributed to Qt in order to help our development.
At the end, you will have gained some deep understanding about what is the intended usage of models in Qt.
Stay on top of the latest news, publications, events and more.
Go to Sign-up
Upgrade your applications from Qt 5 to Qt 6 with KDAB’s migration services. Get a free migration assessment and join a hands-on workshop to prepare your team for a successful transition!
Learn more