aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick/itemvariablerefreshrate/doc/src/itemvariablerefreshrate.qdoc
blob: 5be8cd36ebaaa489497b5138864921886820ebe9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
    \title Qt Quick Examples - Item Variable Refresh Rate
    \example itemvariablerefreshrate
    \image qml-itemvariablerefreshrate-example.png
    \brief A Qt Quick example shows how to setup variable refresh rate for
    specific parts of the UI.
    \ingroup qtquickexamples

    This example demonstrates using the live property of a \l{Item Layers} to get a
    variable and independent refresh rate for Quick items. This can provide a significant
    boost to performance if specific parts of a UI does not need to be re-rendered
    every frame, but still require internal updates. Drawing parts that are static
    most of the time or animations that does not have to run smoothly at all times
    is a waste of resources. This property gives the user control over when the item
    is drawn.

    \note Using \l{Item Layers} may involve a performance penalty, depending on the size
    of the layered item subtree, due to using separate render targets (textures),
    which are then blended together in the main render pass.
    Application designers should always evaluate the impact to ensure that the benefits
    of using layers outweigh the potential disadvantages.

    The example uses \l FrameAnimation to control how often the item is rendered.
    Useful when you only want to e.g. every second frame.
    Using something like a timer or other mechanics to toggle the flag is also valid.
    \snippet itemvariablerefreshrate/itemvariablerefreshrate.qml frameAnimation
    In the above snippet, the fps property is only there for visual demonstration purposes.

    The item requires layer.enabled to be true, and then the item will
    be rendered depending on the state of layer.live as shown in the below snippet.
    \snippet itemvariablerefreshrate/itemvariablerefreshrate.qml item
    Using modulo operator and a slider to set the value, we can dynamically change
    how often the Qt logo is rendered.
*/