admin管理员组文章数量:1200781
Problem description:
In Qt5, it was straightforward to work with QML resources in a static library. We simply created a .qrc file to include the QML files along with a qmldir, set QML_IMPORT_PATH for detection in Qt Creator, and used the Q_INIT_RESOURCE macro to initialize resources at runtime.
However, in Qt6, with the introduction of new patches and changes in the CMake workflow, we now need to use the qt_add_qml_module function to generate a .qrc file for QML files.
I also found the generated qrc file and CPP-initialize file. Both files not use the Q_INIT_RESOURCE macros. Which suggests that in a static build, the resources will not be loaded.
Automatically generated resource wrapper:
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
// This file was generated by the qt_add_resources command.
#include <QtCore/qtsymbolmacros.h>
QT_DECLARE_EXTERN_RESOURCE(qmake_QEQuick3d)
namespace {
struct resourceReferenceKeeper {
resourceReferenceKeeper() { QT_KEEP_RESOURCE(qmake_QEQuick3d) }
} resourceReferenceKeeperInstance;
}
Questions:
- What steps should we take when working with a static library that includes QML files?
- Specifically, where should we place the Q_INIT_RESOURCE macro in this new Qt6 setup?
If anyone has experience in packing qml in qt6 into a static library, please share.
本文标签: cQt6 Static linked qml moduleStack Overflow
版权声明:本文标题:c++ - Qt6: Static linked qml module - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738622040a2103245.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论