当前位置: 代码迷 >> QT开发 >> qml project中如何导入qt c++写的插件
  详细解决方案

qml project中如何导入qt c++写的插件

热度:65   发布时间:2016-04-25 04:59:53.0
qml project中怎么导入qt c++写的插件
我有个qml project:
usexx.pro:
C/C++ code
import QmlProject 1.1Project {    mainFile: "usexx.qml"    /* Include .qml, .js, and image files from current directory and subdirectories */    QmlFiles {        directory: "."    }    JavaScriptFiles {        directory: "."    }    ImageFiles {        directory: "."    }    /* List of plugin directories passed to QML runtime */     importPaths: [ "com/xx" ]}


usexx.qml:

C/C++ code
import QtQuick 1.0import com.xx 1.0Rectangle {    width: 360    height: 360    }


com/xx目录下的qmldir文件:
plugin chartsplugin .


怎么没法导入com/xx目录下的插件? 提示:module "com.xx" is not installed


com/xx下的.dll文件有plugin project代码生成:
其中的相关代码如下:
C/C++ code
void ChartsPlugin::registerTypes(const char *uri){    qmlRegisterType<PieChart>("com.xx", 1, 0, "PieChart");    qmlRegisterType<PieSlice>("com.xx", 1, 0, "PieSlice");}Q_EXPORT_PLUGIN2(chartsplugin, ChartsPlugin);



------解决方案--------------------
可以参考我以前写的一篇blog
http://xzis.me/2010/10/hybrid-application-using-qml-and-qt-c/
  相关解决方案