문제

I am newer for coding andorid apps with Qt5.2 using qml,

I want to get a fullscreen app back ground Rectangle with different android device:

Rectangle {
    id:fullscreenbackground
    height: ?
    width: ?     
    ......
}

It seems height or width should been defined explicit and can't use percentage to define.

도움이 되었습니까?

해결책

To resize the top-level item to the view’s size, use QQuickView::setResizeMode():

view.setResizeMode(QQuickView::SizeRootObjectToView);

That overrides any width/height set on the top-level QML item. For non-top-level items use

anchors.fill: parent

On Android, setting the resize mode should suffice. On other platforms, you might have to explicitely show the view in fullscreen:

view.showFullscreen();

다른 팁

What about doing it like this:

Rectangle {
    id:fullscreenbackground
    anchors.fill: parent
    ......
}

A simple one is here!

import QtQuick 2.5
import QtQuick.Controls 1.3
import QtQuick.Window 2.0

ApplicationWindow {
    id: root
    width: Screen.width
    height: Screen.height
    color: "black"
    flags: Qt.FramelessWindowHint

    Rectangle{
        id: fullScreenRectangle
        width: Screen.width
        height: Screen.height
        border.color: "red"
        border.width: 53
        z: 1
    }
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top