Display Frame Rate for the System UI and Applications Example

How to use the FrameTimer to display information about the frame rate.

The "FrameTimer" example with two applications running.

Introduction

This example shows you how to use the FrameTimer component to display frame rate information for both the System UI and the application windows.

The System UI comprises of a column of application icons on the left and a graph on the top right, displaying the average frame rate for the System UI itself. To be more precise, this is the System UI's top-level Window. If there are no applications running, the System UI's frame rate typically stays at 1 Frame per Second (FPS). This is because a Qt QML application window is only redrawn= when necessary. If nothing has changed in this window, it isn't redrawn. System UI's frame rate is then 0 FPS. The only reason the System UI stays around 1 FPS when there are no applications running is because of the FPS graph itself, which is updated once every second and thus causes a redraw of the System UI. This is commonly referred to as the Observer effect.

The Fish application animates, and therefore redraws, at a rate of 25 FPS. So running it will instantly raise the frame-rate of System UI to 25 FPS as well.

        Timer {
            running: true
            repeat: true
            interval: 1000 / 25 // 25 frames per second
            onTriggered: {
                rectangle.rotation = (rectangle.rotation + 5) % 360;
            }
        }
    }

    MouseArea {
        id: mouseArea
        anchors.fill: parent
    }
}

The Rabbit application animates at native speed, which is as fast as the system can or is configured to do, which is usually 60 FPS. Consequently, running this application raises the System UI's FPS further, to 60 FPS.

        RotationAnimation on rotation {
            from: 0; to: 360; loops: Animation.Infinite; duration: 4000
        }
    }

    MouseArea {
        id: mouseArea
        anchors.fill: parent
    }
}

Example project @ code.qt.io

© 2021 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.