QtQml模块提供的C++ API
来源:互联网 发布:程序员要出差吗 编辑:程序博客网 时间:2024/05/22 00:51
QtQml模块提供了一些C++ API,可使用“#include <QtQml>”声明,或者“#include <QtQml/xxx>”单独声明,pro文件中添加“QT += qml”。
QJSEngine:提供了JavaScript代码求值环境。
QJSEngine myEngine; QJSValue three = myEngine.evaluate("1 + 2"); qDebug() << three.toNumber() << endl; // 3 qDebug() << three.toString() << endl; // "3"
QJSValue:Qt/JavaScript数据类型容器。
QJSEngine myEngine; QJSValue myObject = myEngine.newObject(); QJSValue myOtherObject = myEngine.newObject(); myObject.setProperty("myChild", myOtherObject); myObject.setProperty("name", "John Doe"); qDebug() << myObject.property("myChild").toString() << endl; // "[object Object]" qDebug() << myObject.property("name").toString() << endl; // "john Doe"
QJSValueIterator:类Java风格的QJSValue迭代器。
QJSEngine myEngine; QJSValue myObject = myEngine.newObject(); QJSValue myOtherObject = myEngine.newObject(); myObject.setProperty("myChild", myOtherObject); myObject.setProperty("name", "John Doe"); QJSValueIterator it(myObject); while (it.hasNext()) { it.next(); qDebug() << it.name() << ": " << it.value().toString(); } // output // "myChild" : "[object Object]" // "name" : "John Doe"
QQmlAbstractProfilerAdapter:用于QML分析工具。
QQmlAbstarctUrlInterceptor:控制QML文件加载。
QQmlApplicationEngine:从单个QML文件加载应用程序,结合了QQmlEngine和QQmlComponent。
QQmlApplicationEngine engine; engine.load(QUrl(QStringLiteral("qrc:///main.qml")));
QQmlComponent:封装了QML组件的定义。
QQmlEngine engine; QQmlComponent component(&engine, QUrl("qrc:///main.qml")); component.create();
QQmlContext:定义了QML上下文,使用QQmlContext::setContextProperty()可以把C++中的数据暴露到QML文件中。
QQmlEngine engine; MyClass theClass; engine.rootContext()->setContextProperty("theClass", &theClass); // using “theClass”at main.qml QQmlComponent component(&engine, QUrl("qrc:///main.qml")); component.create();
QQmlEngine:提供了实例化QML组件的环境。
QQmlEngine engine; QQmlComponent component(&engine, QUrl("qrc:///main.qml")); component.create();
QQmlError:封装了QML错误信息。
QQmlExpression:在QML上下文中对JavaScript表达式求值。
QQmlEngine engine; QQmlComponent component(&engine, QUrl("qrc:///main.qml")); QObject *object = component.create(); QQmlExpression expr(engine.rootContext(), object, "width * 2"); // width of main.qml is 360 int result = expr.evaluate().toInt(); // result = 720
QQmlExtensionPlugin:作为QML自定义插件的抽象基类。
QQmlFileSelector:在QML文件加载中使用QFileSelector。
QQmlImageProviderBase:通常要注册到QML引擎中,访问数据时必须把QQmlImageProviderBase指针转换为QQuickImageProvider指针。
QQmlIncubationController:精准控制QQmlIncubator实例化过程。
QQmlIncubator:异步创建QML对象。
QQmlEngine engine; QQmlComponent component(&engine, QUrl("qrc:///main.qml")); QQmlIncubator incubator; component.create(incubator); while (incubator.isReady()) { QCoreApplication::processEvents(QEventLoop::AllEvents, 50); } QObject *object = incubator.object();
QQmlListProperty:QML列表属性。
QQmlListReference:处理QQmlListProperty。
QQmlNetworkAccessManagerFactory:为QML引擎创建QNetworkAccessManager实例。
QQmlParserStatus:提供QML解析状态。
QQmlProperty:在C++中访问QML对象属性。
QQmlEngine engine; QQmlComponent component(&engine, QUrl("qrc:///main.qml")); QObject *object = component.create(); QQmlProperty property(object, "width"); qDebug() << "width is" << property.read().toInt() << endl; // width is 360
QQmlPropertyMap:设置key-value对。
QQmlEngine engine; QQmlPropertyMap ownerData; ownerData.insert("name", QVariant(QString("John Smith"))); ownerData.insert("phone", QVariant(QString("555-5555"))); QQmlContext *ctxt = engine.rootContext(); ctxt->setContextProperty("owner", &ownerData); QQmlComponent component(&engine, QUrl("qrc:///main.qml")); component.create(); // using owner at qml file Text { text: owner.name + " " + owner.phone } // shows “John Smith 555-55555”
QQmlPropertyValueSource:属性值源码接口,可以实时更新属性值,语法为<PropertyValueSource> on <property>
QQmlScriptString:封装了脚本内容。
- QtQml模块提供的C++ API
- Video4Linux模块提供的主要API函数
- ngx_lua 模块提供的指令和API等
- QtQml应用程序的性能考虑与建议
- QtQml 应用程序的性能考虑与建议
- qtqml中PropertyAnimation的几种用法
- QtQml应用程序的性能考虑与建议
- QtQml应用程序的性能考虑与建议
- 《扩展和嵌入python解释器》1.12 为扩展模块提供C API
- MySQL 提供的C API ,应用的例子
- 通过MySQL提供的C API访问MySQL数据库
- Zookeeper提供的API
- Redis提供的API
- 使用 twisted 的 txrestapi 模块提供基本的异步 API 服务。
- 通过MySQL C API界面(mysql自己提供的API方式访问mysql数据库)
- ngx_http_core_module模块提供的变量
- JAVA提供的SOCKET API
- highcharts API提供的函数
- codeigniter里的登录跳转
- 推送
- POJ 1065 Wooden Sticks (贪心)
- 电老虎又发威了:凋谢“江南一枝花”
- Selenium2.0之WebDriver学习总结(一)
- QtQml模块提供的C++ API
- Selenium2.0之WebDriver学习总结(三)
- Java集合类型Collection详解
- OpenGL 多边形偏移高亮物体边 Polygon offset
- 1的平方加到n的平方
- 计算文件夹下文件的总大小
- 全球MAC地址与本地MAC地址
- 推送相关
- Android:TextView中文本的不同颜色