O'Reilly logo

Game Programming using Qt 5 Beginner's Guide - Second Edition by Lorenz Haas, Witold Wysota, Pavel Strakhov

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

Graphical effects

The basic two predefined items in Qt Quick are rectangle and image. You can use them in a variety of creative ways and make them more pleasant-looking by applying GLSL shaders. However, implementing a shader program from scratch is cumbersome and requires in-depth knowledge of the shader language. Luckily, a number of common effects are already implemented and ready to use in the form of the QtGraphicalEffects module.

To add a subtle black shadow to our canvas-based heartbeat element defined in the HeartBeat.qml file, use a code similar to the following that makes use of the DropShadow effect:

import QtQuick 2.9import QtQuick.Window 2.2import QtGraphicalEffects 1.0Window {    //...    HeartBeat {        id: heartBeat anchors.centerIn: ...

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