PySide6.QtQml.QJSPrimitiveValue¶
- class QJSPrimitiveValue¶
- The - QJSPrimitiveValueclass operates on primitive types in JavaScript semantics. More…- Synopsis¶- Methods¶- def - __init__()
- def - constData()
- def - data()
- def - equals()
- def - metaType()
- def - __ne__()
- def - __mod__()
- def - __mul__()
- def - __add__()
- def - __iadd__()
- def - __sub__()
- def - __isub__()
- def - __div__()
- def - __lt__()
- def - __le__()
- def - __eq__()
- def - __gt__()
- def - __ge__()
- def - strictlyEquals()
- def - toBoolean()
- def - toDouble()
- def - toInteger()
- def - toString()
- def - toVariant()
- def - type()
 - Note - This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE - Detailed Description¶- QJSPrimitiveValuesupports 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- QJSPrimitiveValueand 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- QJSPrimitiveValuefrom a different thread than it was created in. On the flip side,- QJSPrimitiveValuedoes not hold a reference to any JavaScript engine.- QJSPrimitiveValueimplements 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 Type¶
- This enum speicifies the types a - QJSPrimitiveValuemight 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. 
 - __init__()¶
 - Creates a - QJSPrimitiveValueof type Undefined.- __init__(type)
- Parameters:
- type – - QMetaType
 
 - __init__(string)
- Parameters:
- string – str 
 
 - Creates a - QJSPrimitiveValueof value- valueand type String.- __init__(value)
- Parameters:
- value – bool 
 
 - Creates a - QJSPrimitiveValueof value- valueand type Boolean.- __init__(variant)
- Parameters:
- variant – object 
 
 - Creates a - QJSPrimitiveValuefrom the contents of- valueif those contents can be stored in QJSPrimtiveValue. Otherwise this results in a- QJSPrimitiveValueof type Undefined.- __init__(value)
- Parameters:
- value – float 
 
 - Creates a - QJSPrimitiveValueof value- valueand type Double.- __init__(value)
- Parameters:
- value – int 
 
 - Creates a - QJSPrimitiveValueof value- valueand type Integer.- __init__(type, value)
- Parameters:
- type – - QMetaType
- value – - void
 
 
 - Creates a - QJSPrimitiveValueof type- type, and initializes with- valueif- typecan be stored in QJSPrimtiveValue.- valuemust not be nullptr in that case. If- typecannot be stored this results in a- QJSPrimitiveValueof type Undefined.- Note that you have to pass the address of the variable you want stored. - Usually, you never have to use this constructor, use the one taking QVariant instead. - constData()¶
- Return type:
- void
 
 - data()¶
- Return type:
- void
 
 - equals(other)¶
- Parameters:
- other – - QJSPrimitiveValue
- Return type:
- bool 
 
 - Performs the JavaScript ‘==’ operation on this - QJSPrimitiveValueand- other, and returns the result.- Returns the QMetaType of the value stored in the - QJSPrimitiveValue.- __ne__(rhs)¶
- Parameters:
- rhs – - QJSPrimitiveValue
- Return type:
- bool 
 
 - Performs the JavaScript ‘!==’ operation on - lhsand- rhs, and returns the result.- __mod__(rhs)¶
- Parameters:
- rhs – - QJSPrimitiveValue
- Return type:
 
 - __mul__(rhs)¶
- Parameters:
- rhs – - QJSPrimitiveValue
- Return type:
 
 - Performs the JavaScript ‘*’ operation on - lhsand- rhs, and returns the result.- __add__()¶
- Return type:
 
 - __add__(rhs)
- Parameters:
- rhs – - QJSPrimitiveValue
- Return type:
 
 - Perfoms the JavaScript ‘+’ operation on - lhsand- rhs, and returns the result.- __iadd__()¶
- Return type:
 
 - __iadd__(arg__1)
- Parameters:
- arg__1 – int 
- Return type:
 
 - __sub__()¶
- Return type:
 
 - __sub__(rhs)
- Parameters:
- rhs – - QJSPrimitiveValue
- Return type:
 
 - Performs the JavaScript ‘-’ operation on - lhsand- rhs, and returns the result.- __isub__()¶
- Return type:
 
 - __isub__(arg__1)
- Parameters:
- arg__1 – int 
- Return type:
 
 - __div__(rhs)¶
- Parameters:
- rhs – - QJSPrimitiveValue
- Return type:
 
 - Performs the JavaScript ‘/’ operation between - lhsand- rhs, and returns the result.- __lt__(rhs)¶
- Parameters:
- rhs – - QJSPrimitiveValue
- Return type:
- bool 
 
 - Performs the JavaScript ‘<’ operation on - lhsand- rhs, and returns the result.- __le__(rhs)¶
- Parameters:
- rhs – - QJSPrimitiveValue
- Return type:
- bool 
 
 - Performs the JavaScript ‘<=’ operation on - lhsand- rhs, and returns the result.- __eq__(rhs)¶
- Parameters:
- rhs – - QJSPrimitiveValue
- Return type:
- bool 
 
 - Performs the JavaScript ‘===’ operation on - lhsand- rhs, and returns the result.- __gt__(rhs)¶
- Parameters:
- rhs – - QJSPrimitiveValue
- Return type:
- bool 
 
 - Performs the JavaScript ‘>’ operation on - lhsand- rhs, and returns the result.- __ge__(rhs)¶
- Parameters:
- rhs – - QJSPrimitiveValue
- Return type:
- bool 
 
 - Performs the JavaScript ‘>=’ operation on - lhsand- rhs, and returns the result.- strictlyEquals(other)¶
- Parameters:
- other – - QJSPrimitiveValue
- Return type:
- bool 
 
 - Performs the JavaScript ‘===’ operation on this - QJSPrimitiveValueand- other, and returns the result.- toBoolean()¶
- Return type:
- bool 
 
 - Returns the value coerced a boolean by JavaScript rules. - toDouble()¶
- Return type:
- float 
 
 - Returns the value coerced to a JavaScript Number by JavaScript rules. - 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. - toString()¶
- Return type:
- str 
 
 - Returns the value coerced to a JavaScript String by JavaScript rules. - toVariant()¶
- Return type:
- object 
 
 - Returns the type of the - QJSPrimitiveValue.