QML使用dll插件封装

首先,看了许多例子,都会出现xxxx  module not installed!

发的文章也都是抄来抄去,没啥意思,说的让人半懂不懂。

经过反反复复的折腾,终于弄出来了。

描述:QT5.11  win10

1.qml文件并不能完全的隐藏方法。意思就是说你新建了一个工程,引用这个模块,需要

注:第二个文件名称为plugins.qmltypes。因为我截图截错了,下图同。(不再标明)

这4个或者5个文件,如果缺少qml文件(debug编译使用xxxxxxd.dll.release使用xxxxxx.dll)

所以,只有dll和qmldir是不行的。

2.qmldir内容

module com.mycompany.qmlcomponents
plugin QMLPlugin
typeinfo plugins.qmltypes

MyRect 1.0 MyRect.qml

designersupported

3.import路径问题

pro文件的path应该为A处

QML_IMPORT_PATH = E:\QML_Custom_model

main.cpp

engine.addImportPath("E:/QML_Custom_model");

4.plugins.qmltypes

import QtQuick.tooling 1.2

// This file describes the plugin-supplied types contained in the library.
// It is used for QML tooling purposes only.
//
// This file was auto-generated by:
// 'qmlplugindump com.mycompany.qmlcomponents 1.0 E:\T\QMLPlugin\QMLPluginTest'

Module {
    dependencies: []
    Component {
        name: "MyItem"
        defaultProperty: "data"
        prototype: "QQuickItem"
        exports: ["MyItem 1.0"]
        exportMetaObjectRevisions: [0]
    }
    Component {
        name: "QQuickItem"
        defaultProperty: "data"
        prototype: "QObject"
        Enum {
            name: "TransformOrigin"
            values: {
                "TopLeft": 0,
                "Top": 1,
                "TopRight": 2,
                "Left": 3,
                "Center": 4,
                "Right": 5,
                "BottomLeft": 6,
                "Bottom": 7,
                "BottomRight": 8
            }
        }
        Property { name: "parent"; type: "QQuickItem"; isPointer: true }
        Property { name: "data"; type: "QObject"; isList: true; isReadonly: true }
        Property { name: "resources"; type: "QObject"; isList: true; isReadonly: true }
        Property { name: "children"; type: "QQuickItem"; isList: true; isReadonly: true }
        Property { name: "x"; type: "double" }
        Property { name: "y"; type: "double" }
        Property { name: "z"; type: "double" }
        Property { name: "width"; type: "double" }
        Property { name: "height"; type: "double" }
        Property { name: "opacity"; type: "double" }
        Property { name: "enabled"; type: "bool" }
        Property { name: "visible"; type: "bool" }
        Property { name: "visibleChildren"; type: "QQuickItem"; isList: true; isReadonly: true }
        Property { name: "states"; type: "QQuickState"; isList: true; isReadonly: true }
        Property { name: "transitions"; type: "QQuickTransition"; isList: true; isReadonly: true }
        Property { name: "state"; type: "string" }
        Property { name: "childrenRect"; type: "QRectF"; isReadonly: true }
        Property { name: "anchors"; type: "QQuickAnchors"; isReadonly: true; isPointer: true }
        Property { name: "left"; type: "QQuickAnchorLine"; isReadonly: true }
        Property { name: "right"; type: "QQuickAnchorLine"; isReadonly: true }
        Property { name: "horizontalCenter"; type: "QQuickAnchorLine"; isReadonly: true }
        Property { name: "top"; type: "QQuickAnchorLine"; isReadonly: true }
        Property { name: "bottom"; type: "QQuickAnchorLine"; isReadonly: true }
        Property { name: "verticalCenter"; type: "QQuickAnchorLine"; isReadonly: true }
        Property { name: "baseline"; type: "QQuickAnchorLine"; isReadonly: true }
        Property { name: "baselineOffset"; type: "double" }
        Property { name: "clip"; type: "bool" }
        Property { name: "focus"; type: "bool" }
        Property { name: "activeFocus"; type: "bool"; isReadonly: true }
        Property { name: "activeFocusOnTab"; revision: 1; type: "bool" }
        Property { name: "rotation"; type: "double" }
        Property { name: "scale"; type: "double" }
        Property { name: "transformOrigin"; type: "TransformOrigin" }
        Property { name: "transformOriginPoint"; type: "QPointF"; isReadonly: true }
        Property { name: "transform"; type: "QQuickTransform"; isList: true; isReadonly: true }
        Property { name: "smooth"; type: "bool" }
        Property { name: "antialiasing"; type: "bool" }
        Property { name: "implicitWidth"; type: "double" }
        Property { name: "implicitHeight"; type: "double" }
        Property { name: "containmentMask"; revision: 11; type: "QObject"; isPointer: true }
        Property { name: "layer"; type: "QQuickItemLayer"; isReadonly: true; isPointer: true }
        Signal {
            name: "childrenRectChanged"
            Parameter { type: "QRectF" }
        }
        Signal {
            name: "baselineOffsetChanged"
            Parameter { type: "double" }
        }
        Signal {
            name: "stateChanged"
            Parameter { type: "string" }
        }
        Signal {
            name: "focusChanged"
            Parameter { type: "bool" }
        }
        Signal {
            name: "activeFocusChanged"
            Parameter { type: "bool" }
        }
        Signal {
            name: "activeFocusOnTabChanged"
            revision: 1
            Parameter { type: "bool" }
        }
        Signal {
            name: "parentChanged"
            Parameter { type: "QQuickItem"; isPointer: true }
        }
        Signal {
            name: "transformOriginChanged"
            Parameter { type: "TransformOrigin" }
        }
        Signal {
            name: "smoothChanged"
            Parameter { type: "bool" }
        }
        Signal {
            name: "antialiasingChanged"
            Parameter { type: "bool" }
        }
        Signal {
            name: "clipChanged"
            Parameter { type: "bool" }
        }
        Signal {
            name: "windowChanged"
            revision: 1
            Parameter { name: "window"; type: "QQuickWindow"; isPointer: true }
        }
        Signal { name: "containmentMaskChanged"; revision: 11 }
        Method { name: "update" }
        Method {
            name: "grabToImage"
            revision: 2
            type: "bool"
            Parameter { name: "callback"; type: "QJSValue" }
            Parameter { name: "targetSize"; type: "QSize" }
        }
        Method {
            name: "grabToImage"
            revision: 2
            type: "bool"
            Parameter { name: "callback"; type: "QJSValue" }
        }
        Method {
            name: "contains"
            type: "bool"
            Parameter { name: "point"; type: "QPointF" }
        }
        Method {
            name: "mapFromItem"
            Parameter { type: "QQmlV4Function"; isPointer: true }
        }
        Method {
            name: "mapToItem"
            Parameter { type: "QQmlV4Function"; isPointer: true }
        }
        Method {
            name: "mapFromGlobal"
            revision: 7
            Parameter { type: "QQmlV4Function"; isPointer: true }
        }
        Method {
            name: "mapToGlobal"
            revision: 7
            Parameter { type: "QQmlV4Function"; isPointer: true }
        }
        Method { name: "forceActiveFocus" }
        Method {
            name: "forceActiveFocus"
            Parameter { name: "reason"; type: "Qt::FocusReason" }
        }
        Method {
            name: "nextItemInFocusChain"
            revision: 1
            type: "QQuickItem*"
            Parameter { name: "forward"; type: "bool" }
        }
        Method { name: "nextItemInFocusChain"; revision: 1; type: "QQuickItem*" }
        Method {
            name: "childAt"
            type: "QQuickItem*"
            Parameter { name: "x"; type: "double" }
            Parameter { name: "y"; type: "double" }
        }
    }
}

生成描述文件的方法:

格式:qmlplugindump Arg1 Arg2 Arg3
Arg1 :module名称 Arg2 :module版本 Arg3:插件所在的父路径

1.进入cmd ,cd E:\QML_Custom_model 
2.执行qmlplugindump com.mycompany.qmlcomponents 1.0 E:\QML_Custom_model\plugins.qmltypes

至此,关键部分的讲解都已经说完了。这是别人留下的坑。。。。。。。。。。

  • 1
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: Linux、QML和OSM件都是计算机领域的重要概念。 Linux是一个开源的操作系统内核,它可以被用来开发丰富的应用程序。Linux支持多种硬件设备和处理器架构,这使得它在工业和企业领域都拥有广泛的应用。Linux是高度可定制和可配置的,并且它具有强大的网络能力和安全性。 QML是Qt Quick Markup Language的缩写,是一种基于JavaScript的用户界面开发语言。QML被广泛使用于Qt应用程序的开发,Qt是一个跨平台的应用程序开发框架。QML具有声明式语法和严格的类型系统,这使得它在开发图形用户界面时非常方便和高效。 OSM件是一个基于OpenStreetMap的编程接口。OpenStreetMap是一个免费的、可编辑的在线地图服务,用户可以在上面添加、修改和删除地图中的数据。OSM件为开发者提供了使用OpenStreetMap数据的接口,它可以轻松地将OpenStreetMap数据整合到开发的应用程序中。 综合而言,Linux、QML和OSM件都是开发人员必须熟悉和掌握的概念。Linux提供了一个强大的操作系统内核用于应用程序的开发和部署;QML提供了一个高效、灵活的用户界面开发语言;OSM件为应用程序提供了开放的地图数据接口,帮助应用程序实现更精细的地理信息展示和交互。 ### 回答2: Linux QML OSM 件是一个功能强大的工具,它可以帮助开发者在 Linux 操作系统中使用 OSM(OpenStreetMap)地图。OSM 是一个开源、免费的地图服务,它的数据可以被任何人免费使用和修改。有了这个件,开发者可以将 OSM 地图集成到他们的应用程序中,从而为用户提供定位、导航和位置信息。QML 是一种用于开发跨平台用户界面的技术,它可以方便地与其他编程语言集成,而且具有良好的性能和易用性。因此,Linux QML OSM 件具有灵活和可扩展的特点,使其成为一个受欢迎的工具。 使用 Linux QML OSM 件,开发者可以在应用程序中轻松地显示 OSM 地图,并在地图上添加自定义图层、标签和其他元素。该件还提供了强大的地理编码和路径规划功能,使应用程序能够更准确地解析用户输入的地理位置信息,以及计算出最佳的路径和距离。此外,该件还支持离线地图缓存,使用户可以在没有互联网连接的情况下使用地图。 总的来说,Linux QML OSM 件是一个非常有用的工具,它可以帮助开发者轻松地将 OSM 地图集成到他们的应用程序中,并提供了高度可定制的功能,使应用程序拥有良好的用户体验。同时,由于 OSM 数据是完全开放的,因此该件还可以为开发者们提供更多的自由和创新空间。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值