Qt wiki will be updated on October 12th 2023 starting at 11:30 AM (EEST) and the maintenance will last around 2-3 hours. During the maintenance the site will be unavailable.

Property-var: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
 
(Cleanup)
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
==QtQuick 1.x==
== QtQuick 1.x ==
 
* There was no javascript var type property, but property variant, internally a QVariant.
* There was no javascript var type property, but property variant, internally a QVariant.
* Assigning a JavaScript object to that property would result in it being converted to a QVariantMap.
* Assigning a JavaScript object to that property would result in it being converted to a QVariantMap.
* Accessing that property from JS would result in that QVariantMap being converted back into a JS object.
* Accessing that property from JS would result in that QVariantMap being converted back into a JS object.
* JS function reference, special JS values (null, undefined) could not be stored in the ‘property variant’ type of property.
* JS function reference, special JS values (null, undefined) could not be stored in the 'property variant' type of property.


==QtQuick 2.0==
== QtQuick 2.0 ==


* Deprecated “property variant” and added “property var; internally they are javascript values.
* Deprecated "property variant" and added "property var; internally they are javascript values.
* Support storing of anything created in JS, including JS function references.
* Support storing of anything created in JS, including JS function references.
* Only when accessed from C++ (via QObject::property() or QQmlProperty::read()) will be converted to a QVariant (same conversions rules of any other JS value to QVariant conversion apply).
* Only when accessed from C++ (via QObject::property() or QQmlProperty::read()) will be converted to a QVariant (same conversions rules of any other JS value to QVariant conversion apply).
* When implementing types on the C++ side, one can use the <span class="caps">QJSV</span>alue class as a property/method parameter to transfer values between C++ and <span class="caps">QML</span>/JS without type/data loss.
* When implementing types on the C++ side, one can use the QJSValue class as a property/method parameter to transfer values between C++ and QML/JS without type/data loss.
** Includes JS functions; for example, you can assign a function to a property from <span class="caps">QML</span> and call it later from C++ using <span class="caps">QJSV</span>alue::call().
** Includes JS functions; for example, you can assign a function to a property from QML and call it later from C++ using QJSValue::call().
* There’s also QJson{Value,Object,Array} integration.

Latest revision as of 21:46, 28 June 2015

QtQuick 1.x

  • There was no javascript var type property, but property variant, internally a QVariant.
  • Assigning a JavaScript object to that property would result in it being converted to a QVariantMap.
  • Accessing that property from JS would result in that QVariantMap being converted back into a JS object.
  • JS function reference, special JS values (null, undefined) could not be stored in the 'property variant' type of property.

QtQuick 2.0

  • Deprecated "property variant" and added "property var; internally they are javascript values.
  • Support storing of anything created in JS, including JS function references.
  • Only when accessed from C++ (via QObject::property() or QQmlProperty::read()) will be converted to a QVariant (same conversions rules of any other JS value to QVariant conversion apply).
  • When implementing types on the C++ side, one can use the QJSValue class as a property/method parameter to transfer values between C++ and QML/JS without type/data loss.
    • Includes JS functions; for example, you can assign a function to a property from QML and call it later from C++ using QJSValue::call().