QT中qmlRegisterTypeqmlRegisterSingletonType的区别qmlRegisterType qmlRegisterSingletonType
了解设计模式的肯定知道单根模式,这个qmlRegisterSingletonType函数意思能就是注册⼀个单根类型到QML中,看看他们的完整声明:int qmlRegisterSingletonType(const char *uri, int versionMajor, int versionMinor, const char *typeName, QJSValue(* ) ( QQmlEngine *, QJSEngine * ) callback)
七年级下册英语
int qmlRegisterSingletonType(const char *uri, int versionMajor, int versionMinor, const char *typeName,
QObject *(* ) ( QQmlEngine *, QJSEngine * ) callback)
int qmlRegisterSingletonType(const QUrl &url, const char *uri, int versionMajor, int versionMinor, const char *qmlName)前两个函数通过回调函数返回类型的实例,第三个函数通过URL⽣成实例indispensable
// First, define the singleton type provider function (callback).
static QJSValue example_qjsvalue_singletontype_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
trustme
digital是什么意思{
Q_UNUSED(engine)
static int edValue = 5;
QJSValue example = scriptEngine->newObject();
example.tProperty("someProperty", edValue++);
return example;
上海市延安中学}
// Second, register the singleton type provider with QML by calling this function in an initialization function.
#include <QtQml>
英文童话>zbb...
qmlRegisterSingletonType("Qt.example.qjsvalueApi", 1, 0, "MyApi", example_qjsvalue_singletontype_provider);
resistant是什么意思...
qml中这样使⽤
import QtQuick 2.0
ample.qjsvalueApi 1.0 as ExampleApi
Item {
id: root
property int someValue: ExampleApi.MyApi.someProperty
}
于园翻译培训公开课未写完,待续