Testing QtQuick on Raspberry Pi

So now you have a shiny new Qt build on your Raspberry Pi. Now what ? Testing!

This tutorial presents a very simple, sort-of a Hello World QtQuick applications.

Start your favorite editor (nano, vi, emacs, editor-of-choice) and paste the following code into it and then save it as main.qml

A simple QtQuick example

import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Controls 2.12

ApplicationWindow {
    visible: true
    width: 1920
    height: 1080
    visibility: Window.FullScreen
    title: qsTr("Hello World")

    Page {
        anchors.fill: parent
        focus: true
        Rectangle {
            color: "#e8e8e8"
            anchors.centerIn: parent
            width: 800
            height: 600
            Image {
                id: debianLogo
                fillMode: Image.PreserveAspectFit
                anchors.centerIn: parent
                source: "/usr/share/pixmaps/debian-logo.png"
            }
            Label {
                anchors.top: debianLogo.bottom
                text: "Hello World From QtQuick!"
            }
        }
        Keys.onReleased: {
            if (event.key === Qt.Key_Escape) {
                Qt.quit()
            }
        }
    }
}

Run the example QtQuick application

As this example  is pure QtQuick, no C++, we can run it with qmlscene. Run the following command, adjust the path for your Qt installation prefix:

/opt/Qt/5.12.10/bin/qmlscene main.qml

You should now see grey box in the middle of the screen with the Debian logo in the center. Press ESC to exit the test application.

Problems with Qt on the Pi ?

Issue Solutions

App exists with:

Could not queue DRM page flip on screen HDMI1 (Invalid argument)

Set the environment variable:

QT_QPA_EGLFS_ALWAYS_SET_MODE=1