C

JavaScript environment for Qt Quick Ultralite applications

Qt Quick Ultralite is designed with performance and code size in mind. Therefore the QML layer is intended only for visual presentation of an application and business logic of an application should be done in C++. Qt Quick Ultralite provides C++ API which make the inter-operation between QML and C++ a straightforward and boilerplate code free process. For more information, see Integrating C++ code with QML.

Qt Quick Ultralite does not provide full JavaScript runtime but it provides most commonly used APIs that allow you to write script expressions. If you believe that some important API is missing, contact Qt Professional Services.

JavaScript objects and functions

The Global Object

In the JavaScript The Global Object object, Qt Quick Ultralite supports the following methods:

  • isFinite(x)
  • isNaN(x)

Math

In the JavaScript Math object, Qt Quick Ultralite supports the following methods:

  • sin(v)
  • cos(v)
  • tan(v)
  • asin(v)
  • acos(v)
  • atan2(a, b)
  • sqrt(v)
  • round(v)
  • floor(v)
  • ceil(v)
  • abs(v)
  • max(v1, v2)
  • min(v1, v2)

In Math.max and Math.min, you can only use two arguments.

Note: The math operations are done with the float C++ type and might return wrong result if you use them with large integer values.

Date

Only empty Date constructor is supported. There is a known behavior difference that in Qt Quick Ultralite default constructed Date returns elapsed time since when the program was started, instead of current date and time as specified in ECMAScript specification.

In the JavaScript Date object, Qt Quick Ultralite supports the following methods:

  • getHours()
  • getMinutes()
  • getSeconds()

Number

In the JavaScript Number object, Qt Quick Ultralite supports only the the following functions:

  • toString()
  • toFixed(digits)
  • toFixedInt()
  • toExponential(digits)
  • toExponentialAuto()
  • isFinite(v)
  • isInteger(v)
  • isNaN(v)

The toFixedInt() is an equivalent to ECMAScript's toFixed() (called without arguments) The toExponentialAuto() is an equivalent to ECMAScript's toExponential() (called without arguments). These variants are provided as currently default arguments for functions are not supported.

String

In the JavaScript String object, Qt Quick Ultralite supports:

  • charAt(pos)
  • length
  • +, +=, ==, and != operators.

Available under certain Qt licenses.
Find out more.