我没有在默认的qt creator app中更改任何内容,所以一切都应该没问题。我创建了新项目,并尝试编译和运行。编译过程确定,但运行后,找不到main.qml,所以我看到没有任何界面的黑色窗口(应该有hello world text)。
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()
的main.cpp
#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
答案 0 :(得分: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文件在哪里,是否在项目目录中?否则,构建器没有任何要导出到构建目录的内容。