QtDay: Back to Basics: writing a model - a workshop by Giuseppe D'Angelo, KDAB
Good morning, everyone, and welcome! We have a very special workshop for you today by Giuseppe D'Angelo called Back to Basics: writing a model. Just a moment... we see some people coming in. All right. Hi, everyone. Good morning, good morning. Hello. Welcome, everyone! Happy to have you here at Qt Day! Okay, fantastic.
We're going to do a workshop today, Back to Basics: writing a model, and let me go ahead and introduce you all to our workshop speaker today, Giuseppe. Let me bring him live for this part. -Here we go. Hi, Giuseppe! Glad to have you here. -Thank you! Good morning, everyone. -Good morning! Before we get started, I'm just going to tell them all about you, a little bit. Giuseppe is an improver of the Qt project and a software engineer at KDAB. He is a long time contributor to Qt, having used Qt and C++ since 2000. His contributions in Qt range from containers and regular expressions, to GUI widgets and OpenGL.
A free software passionate and UNIX specialist before joining KDAB, Giuseppe organized conferences on open source around Italy. He holds a Bachelor's in Computer Science and, about our workshop today in 2020, let's go back to basics. Writing model and view code is somehow taken for granted. It's, however, a mandatory skill for any proficient Qt developer. Professionals are supposed to be able to write robust, fast, and tested models. And so we'll see how to do
that together in this workshop. And any non-trivial Qt application will feature usages of the model/ view controller framework. And 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. So, what exactly is 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 the models, and how do we test one? So, 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. So, in this workshop we'll write together some models, use them in combination with some other views and, while doing so, show all the best practices associated with such development. Alright. So, I hope you all enjoy. We'll have a short video and then get started. So, talk to you soon!
[intro music] Okay. Here we are. Let me just get started and share the presentation slides. Okay. That's very good. Fantastic. Alright. So once more, good morning, everyone. Thank you very much for the kind introduction to me, and to the workshop. This was actually the subject of the first couple of slides I had here, regarding presenting myself.
I'm kind of a old-timer here at Qt Day. So, I work for KDAB and I write a lot of code related to Qt. So, I decided, this year, not to talk about something new, something bleeding edge, something that is coming with Qt 6. Instead, I decided to go back a little bit and focus on something that I find foundational. And the thing I found foundational this year was writing model/view code. Why is that important to me? Why does this kind of code have this special place in my heart? Well, because I think that, as someone who uses Qt everyday, it's extremely important to understand what are the basic foundations of Qt programming, because the basic stuff is used literally everywhere, even more than the bleeding edge stuff. Maybe you're not running Qt 6 but
might be running Qt 5.15. So, let's focus on something which is there which has been there for a very long time and I don't believe it should be ignored. I believe that this stuff needs to be discussed more and thought more and even improved. And although what I'm going to talk to you about today is model/view programming and model/view programming is a very old thing in Qt, it does not mean that it's somehow perfect and there's nothing to improve there. There is a
lot to learn, regarding the basics. There are still some rough edges around Qt and there is still some evolution happening. Even in Qt 6, we're adding new stuff into model/view programming. So why, specifically, I decided to talk about model/view is model/view is a central framework inside of Qt. Something that I always say when I give this kind of trainings and I give this kind of workshop is that any non-trivial Qt application will use some model/view and some applications actually use model/view, extensively. In any application you're going to write using Qt, there is going to be something which is a list of things, or a table of things, or a tree of things, and these will be data-driven. So you may have a list of wi-fi networks somewhere that you gather somehow and then you need to show it in your UI.