QML 应用程序显示黑屏

QML application displays black screen

我是 QML 的初学者,但我不认为我在项目中做了很多事情,但是当我在 Android 设备上 运行 这个应用程序时,我仍然遇到黑屏。

Main.qml

import QtQuick 2.6
import QtQuick.Window 2.2

Rectangle {
    visible: true
    width: 640
    height: 480

    MouseArea {
        anchors.fill: parent
        onClicked: {
            Qt.quit()
        }
    }

    Text {
        text: qsTr("Hello World")
        anchors.centerIn: parent
    }
}

按钮.QML

import QtQuick 2.0

Rectangle {
    id: mainbtn
    property alias text: lable.text
    width: 165
    height: 50
    radius: 2
    border.width: 2
    Text {
        id: lable
        font.bold: true
        font.pointSize: 17
        width: parent.width
        wrapMode: Text.WordWrap
        horizontalAlignment: Text.AlignHCenter
        anchors.centerIn: parent
    }
    MouseArea {
        anchors.fill: parent
        onClicked: {
            console.log("1")
        }
    }
}

尝试使用 ApplicationWindow 作为根组件

import QtQuick 2.3
import QtQuick.Window 2.2
ApplicationWindow {
    title: qsTr("MyApp")
    Ractangle {
        anchors.fill: parent
        color: “yellow”
    }
}

我意识到我犯的错误。我使用 Qt quick controls application 而不是 Qt Qucik Application

创建了应用程序