QML 我们如何与C++一起使用,有一部份内容保持英文,方便理解 我们知道 ,通过Qt Declarative module , C++可以动态创建和操纵QML 的组件( cpmponents) ,我们利用这些API 使用C++来拓展我们的QML 程序,反过来也可以将QML嵌入到你的C++程序中
通过Qt 的元对象系统( Qt‘s metaobject system),我们可以利用 Qt 中的信号与槽机制使QML 和 Qt objects 相互通信( communicate)
另外,QML plugins可以用来创建可复用的QML 组件
使用C++和 QML 混合编程可能出于以下原因: You may want to mix QML and C++ for a number of reasons
For example: To use functionality defined in a C++ source (for example, when using a C++ Qt-based data model, or calling functions in a third-party C++ library) To access functionality in the Qt Declarative module (for example, to dynamically generate images usingQDeclarativeImageProvider) To write your own QML elements (whether for your applications, or for distribution to others 首先我们介绍下Qt Declarative module 中几个核心的类: QDeclarativeEngine: QML