Qt Quick工程中,添加ui.qml文件无法被其他qml文件找到

我的Qt Creator版本为4.6.2 ,QT版本5.11.

新建空的Qt Quick工程,在其中添加Qt Quick UI File

Xxx.qml代码如下

import QtQuick 2.7
import QtQuick.Window 2.2

Window{
    visible: true
    width: 640
    height: 480
    title: qsTr("Hello World")
    XxxForm{
        anchors.fill:parent
        MouseArea.onClicked: {
            console.log(qsTr('Clicked on background.Text:"'+textEdit.text+'"'))
        }
    }
}

XxxForm.ui.qml代码如下

import QtQuick 2.7

Rectangle {
    property alias MouseArea: mouseArea
    property alias TextEdit: textEdit
    width: 360
    height: 360

    MouseArea {
        id: mouseArea
        anchors.fill: parent
    }

    TextEdit {
        id: textEdit
        Text: qsTr("Enter some text...")
        verticalCenter: Text.AlignHCenter
        anchors.top: parent.top
        anchors.horizontalCenter: parent.horizontalCenter
        anchors.topMargin: 20
        Rectangle {
            anchors.fill: parent
            anchors.margins: -10
            color: "transparent"
            border.width: 1
        }
    }
}

main.cpp如下

#include <QGuiApplication>
#include <QQmlApplicationEngine>

int main(int argc, char *argv[])
{
    QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);

    QGuiApplication app(argc, argv);

    QQmlApplicationEngine engine;
    engine.load(QUrl(QStringLiteral("qrc:/Xxx.qml")));
    if (engine.rootObjects().isEmpty())
        return -1;

    return app.exec();
}

运行后报错如下

QML debugging is enabled. Only use this in a safe environment.
QQmlApplicationEngine failed to load component
qrc:/Xxx.qml:9 Type XxxForm unavailable
qrc:/XxxForm.ui.qml:4 Alias names cannot begin with an upper case letter
qrc:/XxxForm.ui.qml:5 Alias names cannot begin with an upper case letter

但是我在Xxx.qml中点击Xxxform是能进入XxxForm.ui.qml的,但是报错又说无法找到该文件,不知道是啥情况

你的项目是否在改名称之前运行过,如果是,你关闭项目,把编译文件全部删掉再打开从新编译运行试试

qml文件的首字母没有大写