使用qt 打包项目:的文章有很多。
例如:
打包的第一步如果使用第三方的数据库或者QML 的文档文件会因为项目加载的是静态库找不到QML 的位置问题而发生报错。
qrc:/main.qml:38 module QtQuick.Window is not installed qrc:/main.qml:37 module QtQuick is not installed qrc:/main.qml:38 module QtQuick.Window is not installed qrc:/main.qml:37 module QtQuick
这里有报错的解决方法。
没哟找到动态的qml 库,那么就需要再main 函数加上目标库的位置。
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCanvas3D module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL3$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 3 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPLv3 included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 3 requirements
** will be met: https://www.gnu.org/licenses/lgpl.html.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 2.0 or later as published by the Free
** Software Foundation and appearing in the file LICENSE.GPL included in
** the packaging of this file. Please review the following information to
** ensure the GNU General Public License version 2.0 requirements will be
** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include <QtGui/QGuiApplication>
#include <QtQml/QQmlApplicationEngine>
int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
//添加库的位置。
engine.addImportPath("D:/QT/5.6/mingw49_32/qml");
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
return app.exec();
}
注意 QML 的库有两个,正确使用的是我main 内部的库的名字,
不是 D:\QT\Tools\QtCreator\bin\qml 。写这个会报错。修改之后,重新 编译构建,之后使用qt 工具 windeployqt cellphone.exe 即可,解决掉以上问题。如果是mysql 的问题,同样修改路径即可解决。