我没有更改默认 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