QML和C ++的結合
• QtQML modules亦提供了從C ++ code執行反
向和操作QML物件的方法
– Interacting with QML Objects from C++
• C ++ code可以結合到C ++應用程序
(application)或C ++插件(plugin)中
– 在C ++插件中提供類型和功能(Providing Types
and Functionality in a C++ Plugin)
5.
QML和C ++的結合 -
註冊Registering
• 可實例化類型 Registering an instantiable type
• the class can be declared and instantiated like any other object type
from QML code
• 不可實例化類型 Registering a non-instantiable type
• Sometimes a QObject-derived class may need to be registered with
the QML type system but not as an instantiable type
– qmlRegisterType() (with no parameters) : base class type
– qmlRegisterInterface() : 註冊為interface type
– qmlRegisterUncreatableType()
– qmlRegisterSingletonType()
6.
QML和C ++的結合 -
鑲嵌Embed by Context Property
• Inject(注入) C++ data into a QML object is
made possible by the QQmlContext class