Qt Quick 组件自定义设置

设置环境变量

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
# Qt  qml 

评论

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×