QML Canvas on Android, orientation problem

I'm new to QML (on Android), so forgive me if this is a trivial thing. I am trying to use a Canvas object to draw some custom graphs, etc. However, I cannot get him to behave well with a change in screen orientation. If I start my application in portrait orientation, it looks fine until I switch to landscape. The same thing happens if I start his landscape. Everything is fine until I leave the portrait. How can I fix this behavior? Here is a simple test I'm having problems with:

import QtQuick 2.2
import QtQuick.Window 2.1

Window {
    visible: true
    visibility: Window.FullScreen

    Rectangle {
        anchors.fill: parent
        color: "red"

        Canvas {
            anchors.fill: parent

            onPaint: {
                var ctx = getContext("2d")

                ctx.fillStyle = "blue"
                ctx.fillRect(0, 0, width, height)

            }
        }
    }
}

. , , ( , ). , , .

Portrait to landscape

. , ( . , ). , :

enter image description here

+4
2

. , . , . , Ministro , . Qt , . ... Ministro 9.6.8 Qt .

+1

. , "anchors.fill: parent" . , , :

import QtQuick 2.2
import QtQuick.Window 2.1

Window {
    id: root
    width: Screen.width
    height: Screen.height
    visible: true
    visibility: Window.FullScreen


    Rectangle {
        anchors.fill: parent
        width: parent.width
        height: parent.height
        color: "red"

        Canvas {
            anchors.fill: parent
            width: parent.width
            height: parent.height

            onPaint: {
                var ctx = getContext("2d")

                ctx.fillStyle = "blue"
                ctx.fillRect(0, 0, width, height)

            }
        }
    }
}
+1

All Articles