侧边栏壁纸
博主头像
G

  • 累计撰写 77 篇文章
  • 累计创建 44 个标签
  • 累计收到 4 条评论

目 录CONTENT

文章目录

Qt Quick 组件自定义设置

G
G
2021-02-28 / 0 评论 / 0 点赞 / 609 阅读 / 965 字 / 正在检测是否收录...

设置环境变量

GNSoft=D:/workspace

注意:路径分隔符为 "/"

设置工程文件

CONFIG(debug,debug|release){
    DEFINES += control_qml_path=\\\"file:///$$(GNSoft)/qtcontrol\\\"
    DEFINES += control_image_path=\\\"file:///$$(GNSoft)/qtcontrol/GNQuick/Images/\\\"
} else {
    RESOURCES += $$(GNSoft)/qtcontrol/GNQuick/GNQuick.qrc
    DEFINES += control_qml_path=\\\"qrc:///\\\"
    DEFINES += control_image_path=\\\"qrc:/GNQuick/Images/\\\"
}
# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH += $$(GNSoft)/qtcontrol
QML2_IMPORT_PATH += $$(GNSoft)/qtcontrol
# Additional import path used to resolve QML modules just for Qt Quick Designer
QML_DESIGNER_IMPORT_PATH = $$(GNSoft)/qtcontrol

设置main.cpp

#include <QQmlContext>
QQmlApplicationEngine engine;
engine.addImportPath(control_qml_path);
engine.rootContext()->setContextProperty("control_image_path", control_image_path);

引入包

import GNQuick 1.0
0

评论区