QJSPrimitiveValue¶
The QJSPrimitiveValue
class operates on primitive types in JavaScript semantics. More…
Synopsis¶
Functions¶
def
__add__
()def
__add__
(rhs)def
__div__
(rhs)def
__eq__
(rhs)def
__ge__
(rhs)def
__gt__
(rhs)def
__le__
(rhs)def
__lt__
(rhs)def
__mod__
(rhs)def
__mul__
(rhs)def
__ne__
(rhs)def
__sub__
()def
__sub__
(rhs)def
equals
(other)def
operator++
()def
operator++
(arg__1)def
operator--
()def
operator--
(arg__1)def
strictlyEquals
(other)def
toBoolean
()def
toDouble
()def
toInteger
()def
toString
()def
toVariant
()def
type
()
Detailed Description¶
QJSPrimitiveValue
supports most of the primitive types defined in the ECMA-262 standard, in particular Undefined, Boolean, Number, and String. Additionally, you can store a JavaScript null in a QJSPrimitiveValue
and as a special case of Number, you can store an integer value.
All those values are stored immediately, without interacting with the JavaScript heap. Therefore, you can pass QJSPrimitiveValues between different JavaScript engines. In contrast to QJSManagedValue
, there is also no danger in destroying a QJSPrimitiveValue
from a different thread than it was created in. On the flip side, QJSPrimitiveValue
does not hold a reference to any JavaScript engine.
QJSPrimitiveValue
implements the JavaScript arithmetic and comparison operators on the supported types in JavaScript semantics. Types are coerced like the JavaScript engine would coerce them if the operators were written in a JavaScript expression.
The JavaScript Symbol type is not supported as it is of very limited utility regarding arithmetic and comparison operators, the main purpose of QJSPrimitiveValue
. In particular, it causes an exception whenever you try to coerce it to a number or a string, and we cannot throw exceptions without a JavaScript Engine.
- class PySide6.QtQml.QJSPrimitiveValue¶
PySide6.QtQml.QJSPrimitiveValue(string)
PySide6.QtQml.QJSPrimitiveValue(value)
PySide6.QtQml.QJSPrimitiveValue(variant)
PySide6.QtQml.QJSPrimitiveValue(value)
PySide6.QtQml.QJSPrimitiveValue(value)
- Parameters
string – str
value – bool
variant – object
Creates a QJSPrimitiveValue
of type Undefined.
Creates a QJSPrimitiveValue
of value value
and type String.
Creates a QJSPrimitiveValue
of value value
and type Boolean.
Creates a QJSPrimitiveValue
of value value
and type Double.
Creates a QJSPrimitiveValue
of value value
and type Integer.
- PySide6.QtQml.QJSPrimitiveValue.Type¶
This enum speicifies the types a QJSPrimitiveValue
might contain.
Constant
Description
QJSPrimitiveValue.Undefined
The JavaScript Undefined value.
QJSPrimitiveValue.Null
The JavaScript null value. This is in fact not a separate JavaScript type but a special value of the Object type. As it is very common and storable without JavaScript engine, it is still supported.
QJSPrimitiveValue.Boolean
A JavaScript Boolean value.
QJSPrimitiveValue.Integer
An integer. This is a special case of the JavaScript Number type. JavaScript does not have an actual integer type, but the ECMA-262 standard contains rules on how to transform a Number in order to prepare it for certain operators that only make sense on integers, in particular the bit shift operators.
QJSPrimitiveValue
‘s Integer type represents the result of such a transformation.QJSPrimitiveValue.Double
A JavaScript Number value.
QJSPrimitiveValue.String
A JavaScript String value.
- PySide6.QtQml.QJSPrimitiveValue.equals(other)¶
- Parameters
other –
PySide6.QtQml.QJSPrimitiveValue
- Return type
bool
Performs the JavaScript ‘==’ operation on this QJSPrimitiveValue
and other
, and returns the result.
- PySide6.QtQml.QJSPrimitiveValue.__ne__(rhs)¶
- Parameters
- Return type
bool
- PySide6.QtQml.QJSPrimitiveValue.__mod__(rhs)¶
- Parameters
- Return type
- PySide6.QtQml.QJSPrimitiveValue.__mul__(rhs)¶
- Parameters
- Return type
- PySide6.QtQml.QJSPrimitiveValue.__add__()¶
- Return type
- PySide6.QtQml.QJSPrimitiveValue.__add__(rhs)
- Parameters
- Return type
- PySide6.QtQml.QJSPrimitiveValue.operator++(arg__1)
- Parameters
arg__1 – int
- Return type
- PySide6.QtQml.QJSPrimitiveValue.operator++()
- Return type
- PySide6.QtQml.QJSPrimitiveValue.__sub__()¶
- Return type
- PySide6.QtQml.QJSPrimitiveValue.__sub__(rhs)
- Parameters
- Return type
- PySide6.QtQml.QJSPrimitiveValue.operator--()
- Return type
- PySide6.QtQml.QJSPrimitiveValue.operator--(arg__1)
- Parameters
arg__1 – int
- Return type
- PySide6.QtQml.QJSPrimitiveValue.__div__(rhs)¶
- Parameters
- Return type
- PySide6.QtQml.QJSPrimitiveValue.__lt__(rhs)¶
- Parameters
- Return type
bool
- PySide6.QtQml.QJSPrimitiveValue.__le__(rhs)¶
- Parameters
- Return type
bool
- PySide6.QtQml.QJSPrimitiveValue.__eq__(rhs)¶
- Parameters
- Return type
bool
- PySide6.QtQml.QJSPrimitiveValue.__gt__(rhs)¶
- Parameters
- Return type
bool
- PySide6.QtQml.QJSPrimitiveValue.__ge__(rhs)¶
- Parameters
- Return type
bool
- PySide6.QtQml.QJSPrimitiveValue.strictlyEquals(other)¶
- Parameters
other –
PySide6.QtQml.QJSPrimitiveValue
- Return type
bool
Performs the JavaScript ‘===’ operation on this QJSPrimitiveValue
and other
, and returns the result.
- PySide6.QtQml.QJSPrimitiveValue.toBoolean()¶
- Return type
bool
Returns the value coerced a boolean by JavaScript rules.
- PySide6.QtQml.QJSPrimitiveValue.toDouble()¶
- Return type
double
Returns the value coerced to a JavaScript Number by JavaScript rules.
- PySide6.QtQml.QJSPrimitiveValue.toInteger()¶
- Return type
int
Returns the value coerced to an integral 32bit number by the rules JavaScript would apply when preparing it for a bit shift operation.
- PySide6.QtQml.QJSPrimitiveValue.toString()¶
- Return type
str
Returns the value coerced to a JavaScript String by JavaScript rules.
- PySide6.QtQml.QJSPrimitiveValue.toVariant()¶
- Return type
object
Returns the type of the QJSPrimitiveValue
.
© 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.