O'Reilly logo

Application Development with Qt Creator - Second Edition by Ray Rischpater

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Code interlude – Qt Quick and the QML syntax

Most of the programming you do at the lowest level is imperative: you describe how an algorithm should work (take this value and square it, search for the first occurrence of this string and replace it, format this data this way, and so forth). With Qt Quick, your programming is largely declarative: instead of saying how, you say what. For example, in C++ with Qt, we might write code like this to draw a rectangle:

QRect r(0, 0, 16, 16);
QPainter p;
p.setBrush(QBrush(Qt::blue));
p.drawRect(r);

This code creates a rectangle of 16 x 16 pixels, allocates a QPainter object that does the drawing, tells the painter that its brush should be colored blue, and then tells the painter to draw the rectangle. In QML, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required