Qt 打包文件项目以及报错qrc:/main.qml:38 module QtQuick.Window is not installed qrc,以及报错自定义数据的路径问题

使用qt 打包项目:的文章有很多。

例如:

Qt成功打包项目教程_qt项目怎么打包-CSDN博客

打包的第一步如果使用第三方的数据库或者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 的问题,同样修改路径即可解决。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值