0

我没有更改默认 qt creator 应用程序中的任何内容,所以一切都应该没问题。我创建了新项目并尝试编译和运行。编译过程没问题,但是运行后找不到main.qml,所以我只看到没有任何界面的黑色窗口(应该有hello world文本)。

qml1.pro

# Add more folders to ship with the application, here
folder_01.source = qml/qml1
folder_01.target = qml
DEPLOYMENTFOLDERS = folder_01

# Additional import path used to resolve QML modules in Creator's code model
QML_IMPORT_PATH =

# If your application uses the Qt Mobility libraries, uncomment the following
# lines and add the respective components to the MOBILITY variable.
# CONFIG += mobility
# MOBILITY +=

# The .cpp file which was generated for your project. Feel free to hack it.
SOURCES += main.cpp

# Installation path
# target.path =

# Please do not modify the following two lines. Required for deployment.
include(qtquick2applicationviewer/qtquick2applicationviewer.pri)
qtcAddDeployment()

主文件

#include <QtGui/QGuiApplication>
#include "qtquick2applicationviewer.h"

int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);

    QtQuick2ApplicationViewer viewer;
    viewer.setMainQmlFile(QStringLiteral("qml/qml1/main.qml"));
    viewer.showExpanded();

    return app.exec();
}

应用程序从创建者运行后的控制台输出:

QML debugging is enabled. Only use this in a safe environment.
file:///Users/Krab/projects/qtProjects/build-qml1-Desktop_Qt_5_1_1_clang_64bit-Ladění/qml1.app/Contents/Resources/qml/qml1/main.qml: File not found
4

1 回答 1

0

那么我可以在 qml 文件丢失时构建一个应用程序,因为它们没有被处理或任何东西。所以对编译器来说一切似乎都很好。

但我建议您查看目录:Users/Krab/projects/qtProjects/build-qml1-Desktop_Qt_5_1_1_clang_64bit-Ladění/qml1.app/Contents/Resources/qml/qml1/ 检查 QML 文件是否位于该目录中。

另外,您的本地 qml 文件在哪里,它在项目目录中吗?否则,构建器没有任何东西可以导出到构建目录。

于 2013-10-08T12:57:16.747 回答