Introduction to Qt / QML (Part 20) - Local Variables

preview_player
Показать описание
We can't stress this enough: never store any business-related state in QML! All the business logic belongs to C++. However, storing some UI-related state in a component may make sense in certain cases (for instance, the position at which a list view is scrolled to).

How do we do that? In this video we'll show the simplest solution: just introduce some ad-hoc properties in the right element inside a component. These properties can then act as local variables.

About the host:
This video is presented by Jesper Pedersen, who started with Qt back when Qt was widgets only and the version was 1.44, which gives him 21 years of experience with Qt. Since 2000 he has taught almost 100 Qt classes, ranging from Qt Widgets to QML. Heck, Jesper even taught a few classes on QTopia Core — Trolltech's initial attempt at creating a phone stack. Today Jesper holds a fancy business title, but that doesn't prevent him from coding both in his job and in his spare time.

About KDAB:

KDAB experts regularly take time out to deliver KDAB’s world class training, in-house or at open enrollment courses around the world. We are the market leaders for training in Qt, OpenGL and C++.

Рекомендации по теме
Комментарии
Автор

Thanks for your efforts and the videos

senthilandavanp
Автор

This part 20 is brilliantly short indeed. :-)
But it provides the essential about local variables : naming conventions and scope.
A question : the example illustrates their use with signals. This is nice and clear. Now are they also commonly used for property binding ?

jeromelaclavere