Sophie

Sophie

distrib > Mageia > 7 > i586 > media > core-updates > by-pkgid > 6e2327ca1c896c6d674ae53117299f21 > files > 63

qtdeclarative5-doc-5.12.6-1.mga7.noarch.rpm

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qjsvalue.cpp -->
  <title>QJSValue Class | Qt QML 5.12.6</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td >Qt 5.12</td><td ><a href="qtqml-index.html">Qt QML</a></td><td ><a href="qtqml-module.html">C++ Classes</a></td><td >QJSValue</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right"><a href="qtqml-index.html">Qt 5.12.6 Reference Documentation</a></td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#public-types">Public Types</a></li>
<li class="level1"><a href="#public-functions">Public Functions</a></li>
<li class="level1"><a href="#related-non-members">Related Non-Members</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
<li class="level2"><a href="#working-with-arrays">Working With Arrays</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">QJSValue Class</h1>
<!-- $$$QJSValue-brief -->
<p>The <a href="qjsvalue.html">QJSValue</a> class acts as a container for Qt/JavaScript data types. <a href="#details">More...</a></p>
<!-- @@@QJSValue -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign">   <span class="preprocessor">#include &lt;QJSValue&gt;</span>
</td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += qml</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Since:</td><td class="memItemRight bottomAlign">  Qt 5.0</td></tr></table></div><ul>
<li><a href="qjsvalue-members.html">List of all members, including inherited members</a></li>
<li><a href="qjsvalue-obsolete.html">Obsolete members</a></li>
</ul>
<a name="public-types"></a>
<h2 id="public-types">Public Types</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> enum </td><td class="memItemRight bottomAlign"><b><a href="qjsvalue.html#ErrorType-enum">ErrorType</a></b> { GenericError, RangeError, ReferenceError, SyntaxError, TypeError, URIError }</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> enum </td><td class="memItemRight bottomAlign"><b><a href="qjsvalue.html#SpecialValue-enum">SpecialValue</a></b> { UndefinedValue, NullValue }</td></tr>
</table></div>
<a name="public-functions"></a>
<h2 id="public-functions">Public Functions</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qjsvalue.html#QJSValue">QJSValue</a></b>(QJSValue::SpecialValue <i>value</i> = UndefinedValue)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qjsvalue.html#QJSValue-1">QJSValue</a></b>(const QJSValue &amp;<i>other</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qjsvalue.html#QJSValue-2">QJSValue</a></b>(QJSValue &amp;&amp;<i>other</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qjsvalue.html#QJSValue-3">QJSValue</a></b>(bool <i>value</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qjsvalue.html#QJSValue-4">QJSValue</a></b>(int <i>value</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qjsvalue.html#QJSValue-5">QJSValue</a></b>(uint <i>value</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qjsvalue.html#QJSValue-6">QJSValue</a></b>(double <i>value</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qjsvalue.html#QJSValue-7">QJSValue</a></b>(const QString &amp;<i>value</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qjsvalue.html#QJSValue-8">QJSValue</a></b>(const QLatin1String &amp;<i>value</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qjsvalue.html#QJSValue-9">QJSValue</a></b>(const char *<i>value</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qjsvalue.html#dtor.QJSValue">~QJSValue</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QJSValue </td><td class="memItemRight bottomAlign"><b><a href="qjsvalue.html#call">call</a></b>(const QJSValueList &amp;<i>args</i> = ...)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QJSValue </td><td class="memItemRight bottomAlign"><b><a href="qjsvalue.html#callAsConstructor">callAsConstructor</a></b>(const QJSValueList &amp;<i>args</i> = ...)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QJSValue </td><td class="memItemRight bottomAlign"><b><a href="qjsvalue.html#callWithInstance">callWithInstance</a></b>(const QJSValue &amp;<i>instance</i>, const QJSValueList &amp;<i>args</i> = ...)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qjsvalue.html#deleteProperty">deleteProperty</a></b>(const QString &amp;<i>name</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qjsvalue.html#equals">equals</a></b>(const QJSValue &amp;<i>other</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QJSValue::ErrorType </td><td class="memItemRight bottomAlign"><b><a href="qjsvalue.html#errorType">errorType</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qjsvalue.html#hasOwnProperty">hasOwnProperty</a></b>(const QString &amp;<i>name</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qjsvalue.html#hasProperty">hasProperty</a></b>(const QString &amp;<i>name</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qjsvalue.html#isArray">isArray</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qjsvalue.html#isBool">isBool</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qjsvalue.html#isCallable">isCallable</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qjsvalue.html#isDate">isDate</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qjsvalue.html#isError">isError</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qjsvalue.html#isNull">isNull</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qjsvalue.html#isNumber">isNumber</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qjsvalue.html#isObject">isObject</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qjsvalue.html#isQMetaObject">isQMetaObject</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qjsvalue.html#isQObject">isQObject</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qjsvalue.html#isRegExp">isRegExp</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qjsvalue.html#isString">isString</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qjsvalue.html#isUndefined">isUndefined</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qjsvalue.html#isVariant">isVariant</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QJSValue </td><td class="memItemRight bottomAlign"><b><a href="qjsvalue.html#property">property</a></b>(const QString &amp;<i>name</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QJSValue </td><td class="memItemRight bottomAlign"><b><a href="qjsvalue.html#property-1">property</a></b>(quint32 <i>arrayIndex</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QJSValue </td><td class="memItemRight bottomAlign"><b><a href="qjsvalue.html#prototype">prototype</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qjsvalue.html#setProperty">setProperty</a></b>(const QString &amp;<i>name</i>, const QJSValue &amp;<i>value</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qjsvalue.html#setProperty-1">setProperty</a></b>(quint32 <i>arrayIndex</i>, const QJSValue &amp;<i>value</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qjsvalue.html#setPrototype">setPrototype</a></b>(const QJSValue &amp;<i>prototype</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qjsvalue.html#strictlyEquals">strictlyEquals</a></b>(const QJSValue &amp;<i>other</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qjsvalue.html#toBool">toBool</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QDateTime </td><td class="memItemRight bottomAlign"><b><a href="qjsvalue.html#toDateTime">toDateTime</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> qint32 </td><td class="memItemRight bottomAlign"><b><a href="qjsvalue.html#toInt">toInt</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> double </td><td class="memItemRight bottomAlign"><b><a href="qjsvalue.html#toNumber">toNumber</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const QMetaObject *</td><td class="memItemRight bottomAlign"><b><a href="qjsvalue.html#toQMetaObject">toQMetaObject</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QObject *</td><td class="memItemRight bottomAlign"><b><a href="qjsvalue.html#toQObject">toQObject</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qjsvalue.html#toString">toString</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> quint32 </td><td class="memItemRight bottomAlign"><b><a href="qjsvalue.html#toUInt">toUInt</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QVariant </td><td class="memItemRight bottomAlign"><b><a href="qjsvalue.html#toVariant">toVariant</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QJSValue &amp;</td><td class="memItemRight bottomAlign"><b><a href="qjsvalue.html#operator-eq">operator=</a></b>(QJSValue &amp;&amp;<i>other</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QJSValue &amp;</td><td class="memItemRight bottomAlign"><b><a href="qjsvalue.html#operator-eq-1">operator=</a></b>(const QJSValue &amp;<i>other</i>)</td></tr>
</table></div>
<a name="related-non-members"></a>
<h2 id="related-non-members">Related Non-Members</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> typedef </td><td class="memItemRight bottomAlign"><b><a href="qjsvalue.html#QJSValueList-typedef">QJSValueList</a></b></td></tr>
</table></div>
<a name="details"></a>
<!-- $$$QJSValue-description -->
<div class="descr">
<h2 id="details">Detailed Description</h2>
<p>The <a href="qjsvalue.html">QJSValue</a> class acts as a container for Qt/JavaScript data types.</p>
<p><a href="qjsvalue.html">QJSValue</a> supports the types defined in the <a href="http://www.ecma-international.org/publications/standards/Ecma-262.htm">ECMA-262</a> standard: The primitive types, which are Undefined, Null, Boolean, Number, and String; and the Object and Array types. Additionally, built-in support is provided for Qt/C++ types such as QVariant and QObject.</p>
<p>For the object-based types (including Date and RegExp), use the newT() functions in <a href="qjsengine.html">QJSEngine</a> (e.g&#x2e; <a href="qjsengine.html#newObject">QJSEngine::newObject</a>()) to create a <a href="qjsvalue.html">QJSValue</a> of the desired type. For the primitive types, use one of the <a href="qjsvalue.html">QJSValue</a> constructor overloads. For other types, e.g&#x2e; registered gadget types such as QPoint, you can use <a href="qjsengine.html#toScriptValue">QJSEngine::toScriptValue</a>.</p>
<p>The methods named isT() (e.g&#x2e; <a href="qjsvalue.html#isBool">isBool</a>(), <a href="qjsvalue.html#isUndefined">isUndefined</a>()) can be used to test if a value is of a certain type. The methods named toT() (e.g&#x2e; <a href="qjsvalue.html#toBool">toBool</a>(), <a href="qjsvalue.html#toString">toString</a>()) can be used to convert a <a href="qjsvalue.html">QJSValue</a> to another type. You can also use the generic qjsvalue_cast() function.</p>
<p>Object values have zero or more properties which are themselves QJSValues. Use <a href="qjsvalue.html#setProperty">setProperty</a>() to set a property of an object, and call <a href="qjsvalue.html#property">property</a>() to retrieve the value of a property.</p>
<pre class="cpp">

  <span class="type"><a href="qjsengine.html">QJSEngine</a></span> myEngine;
  <span class="type"><a href="qjsvalue.html#QJSValue">QJSValue</a></span> myObject <span class="operator">=</span> myEngine<span class="operator">.</span>newObject();
  <span class="type"><a href="qjsvalue.html#QJSValue">QJSValue</a></span> myOtherObject <span class="operator">=</span> myEngine<span class="operator">.</span>newObject();
  myObject<span class="operator">.</span>setProperty(<span class="string">&quot;myChild&quot;</span><span class="operator">,</span> myOtherObject);
  myObject<span class="operator">.</span>setProperty(<span class="string">&quot;name&quot;</span><span class="operator">,</span> <span class="string">&quot;John Doe&quot;</span>);

</pre>
<p>If you want to iterate over the properties of a script object, use the <a href="qjsvalueiterator.html">QJSValueIterator</a> class.</p>
<p>Object values have an internal <code>prototype</code> property, which can be accessed with <a href="qjsvalue.html#prototype">prototype</a>() and <a href="qjsvalue.html#setPrototype">setPrototype</a>().</p>
<p>Function objects (objects for which <a href="qjsvalue.html#isCallable">isCallable</a>()) returns true) can be invoked by calling <a href="qjsvalue.html#call">call</a>(). Constructor functions can be used to construct new objects by calling <a href="qjsvalue.html#callAsConstructor">callAsConstructor</a>().</p>
<p>Use <a href="qjsvalue.html#equals">equals</a>() or <a href="qjsvalue.html#strictlyEquals">strictlyEquals</a>() to compare a <a href="qjsvalue.html">QJSValue</a> to another.</p>
<p>Note that a <a href="qjsvalue.html">QJSValue</a> for which <a href="qjsvalue.html#isObject">isObject</a>() is true only carries a reference to an actual object; copying the <a href="qjsvalue.html">QJSValue</a> will only copy the object reference, not the object itself. If you want to clone an object (i.e&#x2e; copy an object's properties to another object), you can do so with the help of a <code>for-in</code> statement in script code, or <a href="qjsvalueiterator.html">QJSValueIterator</a> in C++.</p>
<a name="working-with-arrays"></a>
<h3 id="working-with-arrays">Working With Arrays</h3>
<p>To create an array using <a href="qjsvalue.html">QJSValue</a>, use <a href="qjsengine.html#newArray">QJSEngine::newArray</a>():</p>
<pre class="cpp">

  <span class="comment">// Assumes that this class was declared in QML.</span>
  <span class="type"><a href="qjsvalue.html#QJSValue">QJSValue</a></span> jsArray <span class="operator">=</span> engine<span class="operator">-</span><span class="operator">&gt;</span>newArray(<span class="number">3</span>);

</pre>
<p>To set individual elements in the array, use the <a href="qjsvalue.html#setProperty-1">setProperty(quint32 arrayIndex, const QJSValue &amp;value)</a> overload. For example, to fill the array above with integers:</p>
<pre class="cpp">

  <span class="keyword">for</span> (<span class="type">int</span> i <span class="operator">=</span> <span class="number">0</span>; i <span class="operator">&lt;</span> <span class="number">3</span>; <span class="operator">+</span><span class="operator">+</span>i) {
      jsArray<span class="operator">.</span>setProperty(i<span class="operator">,</span> <span class="type">QRandomGenerator</span><span class="operator">::</span>global()<span class="operator">.</span>generate());
  }

</pre>
<p>To determine the length of the array, access the <code>&quot;length&quot;</code> property. To access array elements, use the <a href="qjsvalue.html#property-1">property</a>(quint32 arrayIndex) overload. The following code reads the array we created above back into a list:</p>
<pre class="cpp">

  <span class="type">QVector</span><span class="operator">&lt;</span><span class="type">int</span><span class="operator">&gt;</span> integers;
  <span class="keyword">const</span> <span class="type">int</span> length <span class="operator">=</span> jsArray<span class="operator">.</span>property(<span class="string">&quot;length&quot;</span>)<span class="operator">.</span>toInt();
  <span class="keyword">for</span> (<span class="type">int</span> i <span class="operator">=</span> <span class="number">0</span>; i <span class="operator">&lt;</span> length; <span class="operator">+</span><span class="operator">+</span>i) {
      integers<span class="operator">.</span>append(jsArray<span class="operator">.</span>property(i)<span class="operator">.</span>toInt());
  }

</pre>
</div>
<p><b>See also </b><a href="qjsengine.html">QJSEngine</a> and <a href="qjsvalueiterator.html">QJSValueIterator</a>.</p>
<!-- @@@QJSValue -->
<div class="types">
<h2>Member Type Documentation</h2>
<!-- $$$ErrorType$$$NoError$$$GenericError$$$EvalError$$$RangeError$$$ReferenceError$$$SyntaxError$$$TypeError$$$URIError -->
<h3 class="fn" id="ErrorType-enum"><a name="ErrorType-enum"></a>enum QJSValue::<span class="name">ErrorType</span></h3>
<p>Use this enum for JavaScript language-specific types of Error objects.</p>
<p>They may be useful when emulating language features in C++ requires the use of specialized exception types. In addition, they may help to more clearly communicate certain typical conditions, instead of throwing a generic JavaScript exception. For example, code that deals with networking and resource locators may find it useful to propagate errors related to malformed locators using the URIError type.</p>
<div class="table"><table class="valuelist"><tr valign="top" class="odd"><th class="tblConst">Constant</th><th class="tblval">Value</th><th class="tbldscr">Description</th></tr>
<tr><td class="topAlign"><code>QJSValue::GenericError</code></td><td class="topAlign tblval"><code>1</code></td><td class="topAlign">A generic Error object, but not of a specific sub-type.</td></tr>
<tr><td class="topAlign"><code>QJSValue::RangeError</code></td><td class="topAlign tblval"><code>3</code></td><td class="topAlign">A value did not match the expected set or range.</td></tr>
<tr><td class="topAlign"><code>QJSValue::ReferenceError</code></td><td class="topAlign tblval"><code>4</code></td><td class="topAlign">A non-existing variable referenced.</td></tr>
<tr><td class="topAlign"><code>QJSValue::SyntaxError</code></td><td class="topAlign tblval"><code>5</code></td><td class="topAlign">An invalid token or sequence of tokens was encountered that does not conform with the syntax of the language.</td></tr>
<tr><td class="topAlign"><code>QJSValue::TypeError</code></td><td class="topAlign tblval"><code>6</code></td><td class="topAlign">An operand or argument is incompatible with the type expected.</td></tr>
<tr><td class="topAlign"><code>QJSValue::URIError</code></td><td class="topAlign tblval"><code>7</code></td><td class="topAlign">A URI handling function was used incorrectly or the URI provided is malformed.</td></tr>
</table></div>
<p>This enum was introduced or modified in  Qt 5.12.</p>
<!-- @@@ErrorType -->
<!-- $$$SpecialValue$$$NullValue$$$UndefinedValue -->
<h3 class="fn" id="SpecialValue-enum"><a name="SpecialValue-enum"></a>enum QJSValue::<span class="name">SpecialValue</span></h3>
<p>This enum is used to specify a single-valued type.</p>
<div class="table"><table class="valuelist"><tr valign="top" class="odd"><th class="tblConst">Constant</th><th class="tblval">Value</th><th class="tbldscr">Description</th></tr>
<tr><td class="topAlign"><code>QJSValue::UndefinedValue</code></td><td class="topAlign tblval"><code>1</code></td><td class="topAlign">An undefined value.</td></tr>
<tr><td class="topAlign"><code>QJSValue::NullValue</code></td><td class="topAlign tblval"><code>0</code></td><td class="topAlign">A null value.</td></tr>
</table></div>
<!-- @@@SpecialValue -->
</div>
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$QJSValue[overload1]$$$QJSValueQJSValue::SpecialValue -->
<h3 class="fn" id="QJSValue"><a name="QJSValue"></a>QJSValue::<span class="name">QJSValue</span>(<span class="type"><a href="qjsvalue.html#SpecialValue-enum">QJSValue::SpecialValue</a></span> <i>value</i> = UndefinedValue)</h3>
<p>Constructs a new <a href="qjsvalue.html">QJSValue</a> with a special <i>value</i>.</p>
<!-- @@@QJSValue -->
<!-- $$$QJSValue$$$QJSValueconstQJSValue& -->
<h3 class="fn" id="QJSValue-1"><a name="QJSValue-1"></a>QJSValue::<span class="name">QJSValue</span>(const <span class="type"><a href="qjsvalue.html#QJSValue">QJSValue</a></span> &amp;<i>other</i>)</h3>
<p>Constructs a new <a href="qjsvalue.html">QJSValue</a> that is a copy of <i>other</i>.</p>
<p>Note that if <i>other</i> is an object (i.e&#x2e;, <a href="qjsvalue.html#isObject">isObject</a>() would return true), then only a reference to the underlying object is copied into the new script value (i.e&#x2e;, the object itself is not copied).</p>
<!-- @@@QJSValue -->
<!-- $$$QJSValue$$$QJSValueQJSValue&& -->
<h3 class="fn" id="QJSValue-2"><a name="QJSValue-2"></a>QJSValue::<span class="name">QJSValue</span>(<span class="type"><a href="qjsvalue.html#QJSValue">QJSValue</a></span> &amp;&amp;<i>other</i>)</h3>
<p>Move constructor. Moves from <i>other</i> into this <a href="qjsvalue.html">QJSValue</a> object.</p>
<!-- @@@QJSValue -->
<!-- $$$QJSValue$$$QJSValuebool -->
<h3 class="fn" id="QJSValue-3"><a name="QJSValue-3"></a>QJSValue::<span class="name">QJSValue</span>(<span class="type">bool</span> <i>value</i>)</h3>
<p>Constructs a new <a href="qjsvalue.html">QJSValue</a> with a boolean <i>value</i>.</p>
<!-- @@@QJSValue -->
<!-- $$$QJSValue$$$QJSValueint -->
<h3 class="fn" id="QJSValue-4"><a name="QJSValue-4"></a>QJSValue::<span class="name">QJSValue</span>(<span class="type">int</span> <i>value</i>)</h3>
<p>Constructs a new <a href="qjsvalue.html">QJSValue</a> with a number <i>value</i>.</p>
<!-- @@@QJSValue -->
<!-- $$$QJSValue$$$QJSValueuint -->
<h3 class="fn" id="QJSValue-5"><a name="QJSValue-5"></a>QJSValue::<span class="name">QJSValue</span>(<span class="type">uint</span> <i>value</i>)</h3>
<p>Constructs a new <a href="qjsvalue.html">QJSValue</a> with a number <i>value</i>.</p>
<!-- @@@QJSValue -->
<!-- $$$QJSValue$$$QJSValuedouble -->
<h3 class="fn" id="QJSValue-6"><a name="QJSValue-6"></a>QJSValue::<span class="name">QJSValue</span>(<span class="type">double</span> <i>value</i>)</h3>
<p>Constructs a new <a href="qjsvalue.html">QJSValue</a> with a number <i>value</i>.</p>
<!-- @@@QJSValue -->
<!-- $$$QJSValue$$$QJSValueconstQString& -->
<h3 class="fn" id="QJSValue-7"><a name="QJSValue-7"></a>QJSValue::<span class="name">QJSValue</span>(const <span class="type">QString</span> &amp;<i>value</i>)</h3>
<p>Constructs a new <a href="qjsvalue.html">QJSValue</a> with a string <i>value</i>.</p>
<!-- @@@QJSValue -->
<!-- $$$QJSValue$$$QJSValueconstQLatin1String& -->
<h3 class="fn" id="QJSValue-8"><a name="QJSValue-8"></a>QJSValue::<span class="name">QJSValue</span>(const <span class="type">QLatin1String</span> &amp;<i>value</i>)</h3>
<p>Constructs a new <a href="qjsvalue.html">QJSValue</a> with a string <i>value</i>.</p>
<!-- @@@QJSValue -->
<!-- $$$QJSValue$$$QJSValueconstchar* -->
<h3 class="fn" id="QJSValue-9"><a name="QJSValue-9"></a>QJSValue::<span class="name">QJSValue</span>(const <span class="type">char</span> *<i>value</i>)</h3>
<p>Constructs a new <a href="qjsvalue.html">QJSValue</a> with a string <i>value</i>.</p>
<!-- @@@QJSValue -->
<!-- $$$~QJSValue[overload1]$$$~QJSValue -->
<h3 class="fn" id="dtor.QJSValue"><a name="dtor.QJSValue"></a>QJSValue::<span class="name">~QJSValue</span>()</h3>
<p>Destroys this <a href="qjsvalue.html">QJSValue</a>.</p>
<!-- @@@~QJSValue -->
<!-- $$$call[overload1]$$$callconstQJSValueList& -->
<h3 class="fn" id="call"><a name="call"></a><span class="type"><a href="qjsvalue.html#QJSValue">QJSValue</a></span> QJSValue::<span class="name">call</span>(const <span class="type"><a href="qjsvalue.html#QJSValueList-typedef">QJSValueList</a></span> &amp;<i>args</i> = ...)</h3>
<p>Calls this <a href="qjsvalue.html">QJSValue</a> as a function, passing <i>args</i> as arguments to the function, and using the globalObject() as the &quot;this&quot;-object. Returns the value returned from the function.</p>
<p>If this <a href="qjsvalue.html">QJSValue</a> is not callable, call() does nothing and returns an undefined <a href="qjsvalue.html">QJSValue</a>.</p>
<p>Calling call() can cause an exception to occur in the script engine; in that case, call() returns the value that was thrown (typically an <code>Error</code> object). You can call <a href="qjsvalue.html#isError">isError</a>() on the return value to determine whether an exception occurred.</p>
<p><b>See also </b><a href="qjsvalue.html#isCallable">isCallable</a>(), <a href="qjsvalue.html#callWithInstance">callWithInstance</a>(), and <a href="qjsvalue.html#callAsConstructor">callAsConstructor</a>().</p>
<!-- @@@call -->
<!-- $$$callAsConstructor[overload1]$$$callAsConstructorconstQJSValueList& -->
<h3 class="fn" id="callAsConstructor"><a name="callAsConstructor"></a><span class="type"><a href="qjsvalue.html#QJSValue">QJSValue</a></span> QJSValue::<span class="name">callAsConstructor</span>(const <span class="type"><a href="qjsvalue.html#QJSValueList-typedef">QJSValueList</a></span> &amp;<i>args</i> = ...)</h3>
<p>Creates a new <code>Object</code> and calls this <a href="qjsvalue.html">QJSValue</a> as a constructor, using the created object as the `this' object and passing <i>args</i> as arguments. If the return value from the constructor call is an object, then that object is returned; otherwise the default constructed object is returned.</p>
<p>If this <a href="qjsvalue.html">QJSValue</a> is not a function, callAsConstructor() does nothing and returns an undefined <a href="qjsvalue.html">QJSValue</a>.</p>
<p>Calling this function can cause an exception to occur in the script engine; in that case, the value that was thrown (typically an <code>Error</code> object) is returned. You can call <a href="qjsvalue.html#isError">isError</a>() on the return value to determine whether an exception occurred.</p>
<p><b>See also </b><a href="qjsvalue.html#call">call</a>() and <a href="qjsengine.html#newObject">QJSEngine::newObject</a>().</p>
<!-- @@@callAsConstructor -->
<!-- $$$callWithInstance[overload1]$$$callWithInstanceconstQJSValue&constQJSValueList& -->
<h3 class="fn" id="callWithInstance"><a name="callWithInstance"></a><span class="type"><a href="qjsvalue.html#QJSValue">QJSValue</a></span> QJSValue::<span class="name">callWithInstance</span>(const <span class="type"><a href="qjsvalue.html#QJSValue">QJSValue</a></span> &amp;<i>instance</i>, const <span class="type"><a href="qjsvalue.html#QJSValueList-typedef">QJSValueList</a></span> &amp;<i>args</i> = ...)</h3>
<p>Calls this <a href="qjsvalue.html">QJSValue</a> as a function, using <i>instance</i> as the `this' object in the function call, and passing <i>args</i> as arguments to the function. Returns the value returned from the function.</p>
<p>If this <a href="qjsvalue.html">QJSValue</a> is not a function, <a href="qjsvalue.html#call">call</a>() does nothing and returns an undefined <a href="qjsvalue.html">QJSValue</a>.</p>
<p>Note that if <i>instance</i> is not an object, the global object (see <a href="qjsengine.html#globalObject">QJSEngine::globalObject</a>()) will be used as the `this' object.</p>
<p>Calling <a href="qjsvalue.html#call">call</a>() can cause an exception to occur in the script engine; in that case, <a href="qjsvalue.html#call">call</a>() returns the value that was thrown (typically an <code>Error</code> object). You can call <a href="qjsvalue.html#isError">isError</a>() on the return value to determine whether an exception occurred.</p>
<p><b>See also </b><a href="qjsvalue.html#call">call</a>().</p>
<!-- @@@callWithInstance -->
<!-- $$$deleteProperty[overload1]$$$deletePropertyconstQString& -->
<h3 class="fn" id="deleteProperty"><a name="deleteProperty"></a><span class="type">bool</span> QJSValue::<span class="name">deleteProperty</span>(const <span class="type">QString</span> &amp;<i>name</i>)</h3>
<p>Attempts to delete this object's property of the given <i>name</i>. Returns true if the property was deleted, otherwise returns false.</p>
<p>The behavior of this function is consistent with the JavaScript delete operator. In particular:</p>
<ul>
<li>Non-configurable properties cannot be deleted.</li>
<li>This function will return true even if this object doesn't have a property of the given <i>name</i> (i.e&#x2e;, non-existent properties are &quot;trivially deletable&quot;).</li>
<li>If this object doesn't have an own property of the given <i>name</i>, but an object in the <a href="qjsvalue.html#prototype">prototype</a>() chain does, the prototype object's property is not deleted, and this function returns true.</li>
</ul>
<p><b>See also </b><a href="qjsvalue.html#setProperty">setProperty</a>() and <a href="qjsvalue.html#hasOwnProperty">hasOwnProperty</a>().</p>
<!-- @@@deleteProperty -->
<!-- $$$equals[overload1]$$$equalsconstQJSValue& -->
<h3 class="fn" id="equals"><a name="equals"></a><span class="type">bool</span> QJSValue::<span class="name">equals</span>(const <span class="type"><a href="qjsvalue.html#QJSValue">QJSValue</a></span> &amp;<i>other</i>) const</h3>
<p>Returns true if this <a href="qjsvalue.html">QJSValue</a> is equal to <i>other</i>, otherwise returns false. The comparison follows the behavior described in <a href="http://www.ecma-international.org/publications/standards/Ecma-262.htm">ECMA-262</a> section 11.9&#x2e;3, &quot;The Abstract Equality Comparison Algorithm&quot;.</p>
<p>This function can return true even if the type of this <a href="qjsvalue.html">QJSValue</a> is different from the type of the <i>other</i> value; i.e&#x2e; the comparison is not strict. For example, comparing the number 9 to the string &quot;9&quot; returns true; comparing an undefined value to a null value returns true; comparing a <code>Number</code> object whose primitive value is 6 to a <code>String</code> object whose primitive value is &quot;6&quot; returns true; and comparing the number 1 to the boolean value <code>true</code> returns true. If you want to perform a comparison without such implicit value conversion, use <a href="qjsvalue.html#strictlyEquals">strictlyEquals</a>().</p>
<p>Note that if this <a href="qjsvalue.html">QJSValue</a> or the <i>other</i> value are objects, calling this function has side effects on the script engine, since the engine will call the object's valueOf() function (and possibly <a href="qjsvalue.html#toString">toString</a>()) in an attempt to convert the object to a primitive value (possibly resulting in an uncaught script exception).</p>
<p><b>See also </b><a href="qjsvalue.html#strictlyEquals">strictlyEquals</a>().</p>
<!-- @@@equals -->
<!-- $$$errorType[overload1]$$$errorType -->
<h3 class="fn" id="errorType"><a name="errorType"></a><span class="type"><a href="qjsvalue.html#ErrorType-enum">QJSValue::ErrorType</a></span> QJSValue::<span class="name">errorType</span>() const</h3>
<p>Returns the error type this <a href="qjsvalue.html">QJSValue</a> represents if it is an Error object. Otherwise, returns <code>NoError.&quot;</code></p>
<p>This function was introduced in  Qt 5.12.</p>
<p><b>See also </b><a href="qjsvalue.html#isError">isError</a>() and <a href="qjsengine.html#script-exceptions">QJSEngine - Script Exceptions</a>.</p>
<!-- @@@errorType -->
<!-- $$$hasOwnProperty[overload1]$$$hasOwnPropertyconstQString& -->
<h3 class="fn" id="hasOwnProperty"><a name="hasOwnProperty"></a><span class="type">bool</span> QJSValue::<span class="name">hasOwnProperty</span>(const <span class="type">QString</span> &amp;<i>name</i>) const</h3>
<p>Returns true if this object has an own (not prototype-inherited) property of the given <i>name</i>, otherwise returns false.</p>
<p><b>See also </b><a href="qjsvalue.html#property">property</a>() and <a href="qjsvalue.html#hasProperty">hasProperty</a>().</p>
<!-- @@@hasOwnProperty -->
<!-- $$$hasProperty[overload1]$$$hasPropertyconstQString& -->
<h3 class="fn" id="hasProperty"><a name="hasProperty"></a><span class="type">bool</span> QJSValue::<span class="name">hasProperty</span>(const <span class="type">QString</span> &amp;<i>name</i>) const</h3>
<p>Returns true if this object has a property of the given <i>name</i>, otherwise returns false.</p>
<p><b>See also </b><a href="qjsvalue.html#property">property</a>() and <a href="qjsvalue.html#hasOwnProperty">hasOwnProperty</a>().</p>
<!-- @@@hasProperty -->
<!-- $$$isArray[overload1]$$$isArray -->
<h3 class="fn" id="isArray"><a name="isArray"></a><span class="type">bool</span> QJSValue::<span class="name">isArray</span>() const</h3>
<p>Returns true if this <a href="qjsvalue.html">QJSValue</a> is an object of the Array class; otherwise returns false.</p>
<p><b>See also </b><a href="qjsengine.html#newArray">QJSEngine::newArray</a>().</p>
<!-- @@@isArray -->
<!-- $$$isBool[overload1]$$$isBool -->
<h3 class="fn" id="isBool"><a name="isBool"></a><span class="type">bool</span> QJSValue::<span class="name">isBool</span>() const</h3>
<p>Returns true if this <a href="qjsvalue.html">QJSValue</a> is of the primitive type Boolean; otherwise returns false.</p>
<p><b>See also </b><a href="qjsvalue.html#toBool">toBool</a>().</p>
<!-- @@@isBool -->
<!-- $$$isCallable[overload1]$$$isCallable -->
<h3 class="fn" id="isCallable"><a name="isCallable"></a><span class="type">bool</span> QJSValue::<span class="name">isCallable</span>() const</h3>
<p>Returns true if this <a href="qjsvalue.html">QJSValue</a> can be called a function, otherwise returns false.</p>
<p><b>See also </b><a href="qjsvalue.html#call">call</a>().</p>
<!-- @@@isCallable -->
<!-- $$$isDate[overload1]$$$isDate -->
<h3 class="fn" id="isDate"><a name="isDate"></a><span class="type">bool</span> QJSValue::<span class="name">isDate</span>() const</h3>
<p>Returns true if this <a href="qjsvalue.html">QJSValue</a> is an object of the Date class; otherwise returns false.</p>
<!-- @@@isDate -->
<!-- $$$isError[overload1]$$$isError -->
<h3 class="fn" id="isError"><a name="isError"></a><span class="type">bool</span> QJSValue::<span class="name">isError</span>() const</h3>
<p>Returns true if this <a href="qjsvalue.html">QJSValue</a> is an object of the Error class; otherwise returns false.</p>
<p><b>See also </b><a href="qjsvalue.html#errorType">errorType</a>() and <a href="qjsengine.html#script-exceptions">QJSEngine - Script Exceptions</a>.</p>
<!-- @@@isError -->
<!-- $$$isNull[overload1]$$$isNull -->
<h3 class="fn" id="isNull"><a name="isNull"></a><span class="type">bool</span> QJSValue::<span class="name">isNull</span>() const</h3>
<p>Returns true if this <a href="qjsvalue.html">QJSValue</a> is of the primitive type Null; otherwise returns false.</p>
<!-- @@@isNull -->
<!-- $$$isNumber[overload1]$$$isNumber -->
<h3 class="fn" id="isNumber"><a name="isNumber"></a><span class="type">bool</span> QJSValue::<span class="name">isNumber</span>() const</h3>
<p>Returns true if this <a href="qjsvalue.html">QJSValue</a> is of the primitive type Number; otherwise returns false.</p>
<p><b>See also </b><a href="qjsvalue.html#toNumber">toNumber</a>().</p>
<!-- @@@isNumber -->
<!-- $$$isObject[overload1]$$$isObject -->
<h3 class="fn" id="isObject"><a name="isObject"></a><span class="type">bool</span> QJSValue::<span class="name">isObject</span>() const</h3>
<p>Returns true if this <a href="qjsvalue.html">QJSValue</a> is of the Object type; otherwise returns false.</p>
<p>Note that function values, variant values, and QObject values are objects, so this function returns true for such values.</p>
<p><b>See also </b><a href="qjsengine.html#newObject">QJSEngine::newObject</a>().</p>
<!-- @@@isObject -->
<!-- $$$isQMetaObject[overload1]$$$isQMetaObject -->
<h3 class="fn" id="isQMetaObject"><a name="isQMetaObject"></a><span class="type">bool</span> QJSValue::<span class="name">isQMetaObject</span>() const</h3>
<p>Returns true if this <a href="qjsvalue.html">QJSValue</a> is a QMetaObject; otherwise returns false.</p>
<p>This function was introduced in  Qt 5.8.</p>
<p><b>See also </b><a href="qjsvalue.html#toQMetaObject">toQMetaObject</a>() and <a href="qjsengine.html#newQMetaObject-1">QJSEngine::newQMetaObject</a>().</p>
<!-- @@@isQMetaObject -->
<!-- $$$isQObject[overload1]$$$isQObject -->
<h3 class="fn" id="isQObject"><a name="isQObject"></a><span class="type">bool</span> QJSValue::<span class="name">isQObject</span>() const</h3>
<p>Returns true if this <a href="qjsvalue.html">QJSValue</a> is a QObject; otherwise returns false.</p>
<p>Note: This function returns true even if the QObject that this <a href="qjsvalue.html">QJSValue</a> wraps has been deleted.</p>
<p><b>See also </b><a href="qjsvalue.html#toQObject">toQObject</a>() and <a href="qjsengine.html#newQObject">QJSEngine::newQObject</a>().</p>
<!-- @@@isQObject -->
<!-- $$$isRegExp[overload1]$$$isRegExp -->
<h3 class="fn" id="isRegExp"><a name="isRegExp"></a><span class="type">bool</span> QJSValue::<span class="name">isRegExp</span>() const</h3>
<p>Returns true if this <a href="qjsvalue.html">QJSValue</a> is an object of the RegExp class; otherwise returns false.</p>
<!-- @@@isRegExp -->
<!-- $$$isString[overload1]$$$isString -->
<h3 class="fn" id="isString"><a name="isString"></a><span class="type">bool</span> QJSValue::<span class="name">isString</span>() const</h3>
<p>Returns true if this <a href="qjsvalue.html">QJSValue</a> is of the primitive type String; otherwise returns false.</p>
<p><b>See also </b><a href="qjsvalue.html#toString">toString</a>().</p>
<!-- @@@isString -->
<!-- $$$isUndefined[overload1]$$$isUndefined -->
<h3 class="fn" id="isUndefined"><a name="isUndefined"></a><span class="type">bool</span> QJSValue::<span class="name">isUndefined</span>() const</h3>
<p>Returns true if this <a href="qjsvalue.html">QJSValue</a> is of the primitive type Undefined; otherwise returns false.</p>
<!-- @@@isUndefined -->
<!-- $$$isVariant[overload1]$$$isVariant -->
<h3 class="fn" id="isVariant"><a name="isVariant"></a><span class="type">bool</span> QJSValue::<span class="name">isVariant</span>() const</h3>
<p>Returns true if this <a href="qjsvalue.html">QJSValue</a> is a variant value; otherwise returns false.</p>
<p><b>See also </b><a href="qjsvalue.html#toVariant">toVariant</a>().</p>
<!-- @@@isVariant -->
<!-- $$$property[overload1]$$$propertyconstQString& -->
<h3 class="fn" id="property"><a name="property"></a><span class="type"><a href="qjsvalue.html#QJSValue">QJSValue</a></span> QJSValue::<span class="name">property</span>(const <span class="type">QString</span> &amp;<i>name</i>) const</h3>
<p>Returns the value of this <a href="qjsvalue.html">QJSValue</a>'s property with the given <i>name</i>. If no such property exists, an undefined <a href="qjsvalue.html">QJSValue</a> is returned.</p>
<p>If the property is implemented using a getter function (i.e&#x2e; has the PropertyGetter flag set), calling property() has side-effects on the script engine, since the getter function will be called (possibly resulting in an uncaught script exception). If an exception occurred, property() returns the value that was thrown (typically an <code>Error</code> object).</p>
<p>To access array elements, use the <a href="qjsvalue.html#setProperty-1">setProperty(quint32 arrayIndex, const QJSValue &amp;value)</a> overload instead.</p>
<p><b>See also </b><a href="qjsvalue.html#setProperty">setProperty</a>(), <a href="qjsvalue.html#hasProperty">hasProperty</a>(), and <a href="qjsvalueiterator.html">QJSValueIterator</a>.</p>
<!-- @@@property -->
<!-- $$$property$$$propertyquint32 -->
<h3 class="fn" id="property-1"><a name="property-1"></a><span class="type"><a href="qjsvalue.html#QJSValue">QJSValue</a></span> QJSValue::<span class="name">property</span>(<span class="type">quint32</span> <i>arrayIndex</i>) const</h3>
<p>This is an overloaded function.</p>
<p>Returns the property at the given <i>arrayIndex</i>.</p>
<p>It is possible to access elements in an array in two ways. The first is to use the array index as the property name:</p>
<pre class="cpp">

  qDebug() <span class="operator">&lt;</span><span class="operator">&lt;</span> jsValueArray<span class="operator">.</span>property(QLatin1String(<span class="string">&quot;4&quot;</span>))<span class="operator">.</span>toString();

</pre>
<p>The second is to use the overload that takes an index:</p>
<pre class="cpp">

  qDebug() <span class="operator">&lt;</span><span class="operator">&lt;</span> jsValueArray<span class="operator">.</span>property(<span class="number">4</span>)<span class="operator">.</span>toString();

</pre>
<p>Both of these approaches achieve the same result, except that the latter:</p>
<ul>
<li>Is easier to use (can use an integer directly)</li>
<li>Is faster (no conversion to integer)</li>
</ul>
<p>If this <a href="qjsvalue.html">QJSValue</a> is not an Array object, this function behaves as if <a href="qjsvalue.html#property">property</a>() was called with the string representation of <i>arrayIndex</i>.</p>
<!-- @@@property -->
<!-- $$$prototype[overload1]$$$prototype -->
<h3 class="fn" id="prototype"><a name="prototype"></a><span class="type"><a href="qjsvalue.html#QJSValue">QJSValue</a></span> QJSValue::<span class="name">prototype</span>() const</h3>
<p>If this <a href="qjsvalue.html">QJSValue</a> is an object, returns the internal prototype (<code>__proto__</code> property) of this object; otherwise returns an undefined <a href="qjsvalue.html">QJSValue</a>.</p>
<p><b>See also </b><a href="qjsvalue.html#setPrototype">setPrototype</a>() and <a href="qjsvalue.html#isObject">isObject</a>().</p>
<!-- @@@prototype -->
<!-- $$$setProperty[overload1]$$$setPropertyconstQString&constQJSValue& -->
<h3 class="fn" id="setProperty"><a name="setProperty"></a><span class="type">void</span> QJSValue::<span class="name">setProperty</span>(const <span class="type">QString</span> &amp;<i>name</i>, const <span class="type"><a href="qjsvalue.html#QJSValue">QJSValue</a></span> &amp;<i>value</i>)</h3>
<p>Sets the value of this <a href="qjsvalue.html">QJSValue</a>'s property with the given <i>name</i> to the given <i>value</i>.</p>
<p>If this <a href="qjsvalue.html">QJSValue</a> is not an object, this function does nothing.</p>
<p>If this <a href="qjsvalue.html">QJSValue</a> does not already have a property with name <i>name</i>, a new property is created.</p>
<p>To modify array elements, use the <a href="qjsvalue.html#setProperty-1">setProperty(quint32 arrayIndex, const QJSValue &amp;value)</a> overload instead.</p>
<p><b>See also </b><a href="qjsvalue.html#property">property</a>() and <a href="qjsvalue.html#deleteProperty">deleteProperty</a>().</p>
<!-- @@@setProperty -->
<!-- $$$setProperty$$$setPropertyquint32constQJSValue& -->
<h3 class="fn" id="setProperty-1"><a name="setProperty-1"></a><span class="type">void</span> QJSValue::<span class="name">setProperty</span>(<span class="type">quint32</span> <i>arrayIndex</i>, const <span class="type"><a href="qjsvalue.html#QJSValue">QJSValue</a></span> &amp;<i>value</i>)</h3>
<p>This is an overloaded function.</p>
<p>Sets the property at the given <i>arrayIndex</i> to the given <i>value</i>.</p>
<p>It is possible to modify elements in an array in two ways. The first is to use the array index as the property name:</p>
<pre class="cpp">

  jsValueArray<span class="operator">.</span>setProperty(QLatin1String(<span class="string">&quot;4&quot;</span>)<span class="operator">,</span> value);

</pre>
<p>The second is to use the overload that takes an index:</p>
<pre class="cpp">

  jsValueArray<span class="operator">.</span>setProperty(<span class="number">4</span><span class="operator">,</span> value);

</pre>
<p>Both of these approaches achieve the same result, except that the latter:</p>
<ul>
<li>Is easier to use (can use an integer directly)</li>
<li>Is faster (no conversion to integer)</li>
</ul>
<p>If this <a href="qjsvalue.html">QJSValue</a> is not an Array object, this function behaves as if <a href="qjsvalue.html#setProperty">setProperty</a>() was called with the string representation of <i>arrayIndex</i>.</p>
<p><b>See also </b><a href="qjsvalue.html#property-1">property</a>(quint32 arrayIndex) and <a href="qjsvalue.html#working-with-arrays">Working With Arrays</a>.</p>
<!-- @@@setProperty -->
<!-- $$$setPrototype[overload1]$$$setPrototypeconstQJSValue& -->
<h3 class="fn" id="setPrototype"><a name="setPrototype"></a><span class="type">void</span> QJSValue::<span class="name">setPrototype</span>(const <span class="type"><a href="qjsvalue.html#QJSValue">QJSValue</a></span> &amp;<i>prototype</i>)</h3>
<p>If this <a href="qjsvalue.html">QJSValue</a> is an object, sets the internal prototype (<code>__proto__</code> property) of this object to be <i>prototype</i>; if the <a href="qjsvalue.html">QJSValue</a> is null, it sets the prototype to null; otherwise does nothing.</p>
<p>The internal prototype should not be confused with the public property with name &quot;prototype&quot;; the public prototype is usually only set on functions that act as constructors.</p>
<p><b>See also </b><a href="qjsvalue.html#prototype">prototype</a>() and <a href="qjsvalue.html#isObject">isObject</a>().</p>
<!-- @@@setPrototype -->
<!-- $$$strictlyEquals[overload1]$$$strictlyEqualsconstQJSValue& -->
<h3 class="fn" id="strictlyEquals"><a name="strictlyEquals"></a><span class="type">bool</span> QJSValue::<span class="name">strictlyEquals</span>(const <span class="type"><a href="qjsvalue.html#QJSValue">QJSValue</a></span> &amp;<i>other</i>) const</h3>
<p>Returns true if this <a href="qjsvalue.html">QJSValue</a> is equal to <i>other</i> using strict comparison (no conversion), otherwise returns false. The comparison follows the behavior described in <a href="http://www.ecma-international.org/publications/standards/Ecma-262.htm">ECMA-262</a> section 11.9&#x2e;6, &quot;The Strict Equality Comparison Algorithm&quot;.</p>
<p>If the type of this <a href="qjsvalue.html">QJSValue</a> is different from the type of the <i>other</i> value, this function returns false. If the types are equal, the result depends on the type, as shown in the following table:</p>
<div class="table"><table class="generic">
 <thead><tr class="qt-style"><th >Type</th><th >Result</th></tr></thead>
<tr valign="top" class="odd"><td >Undefined</td><td >true</td></tr>
<tr valign="top" class="even"><td >Null</td><td >true</td></tr>
<tr valign="top" class="odd"><td >Boolean</td><td >true if both values are true, false otherwise</td></tr>
<tr valign="top" class="even"><td >Number</td><td >false if either value is NaN (Not-a-Number); true if values are equal, false otherwise</td></tr>
<tr valign="top" class="odd"><td >String</td><td >true if both values are exactly the same sequence of characters, false otherwise</td></tr>
<tr valign="top" class="even"><td >Object</td><td >true if both values refer to the same object, false otherwise</td></tr>
</table></div>
<p><b>See also </b><a href="qjsvalue.html#equals">equals</a>().</p>
<!-- @@@strictlyEquals -->
<!-- $$$toBool[overload1]$$$toBool -->
<h3 class="fn" id="toBool"><a name="toBool"></a><span class="type">bool</span> QJSValue::<span class="name">toBool</span>() const</h3>
<p>Returns the boolean value of this <a href="qjsvalue.html">QJSValue</a>, using the conversion rules described in <a href="http://www.ecma-international.org/publications/standards/Ecma-262.htm">ECMA-262</a> section 9.2, &quot;ToBoolean&quot;.</p>
<p>Note that if this <a href="qjsvalue.html">QJSValue</a> is an object, calling this function has side effects on the script engine, since the engine will call the object's valueOf() function (and possibly <a href="qjsvalue.html#toString">toString</a>()) in an attempt to convert the object to a primitive value (possibly resulting in an uncaught script exception).</p>
<p><b>See also </b><a href="qjsvalue.html#isBool">isBool</a>().</p>
<!-- @@@toBool -->
<!-- $$$toDateTime[overload1]$$$toDateTime -->
<h3 class="fn" id="toDateTime"><a name="toDateTime"></a><span class="type">QDateTime</span> QJSValue::<span class="name">toDateTime</span>() const</h3>
<p>Returns a QDateTime representation of this value, in local time. If this <a href="qjsvalue.html">QJSValue</a> is not a date, or the value of the date is NaN (Not-a-Number), an invalid QDateTime is returned.</p>
<p><b>See also </b><a href="qjsvalue.html#isDate">isDate</a>().</p>
<!-- @@@toDateTime -->
<!-- $$$toInt[overload1]$$$toInt -->
<h3 class="fn" id="toInt"><a name="toInt"></a><span class="type">qint32</span> QJSValue::<span class="name">toInt</span>() const</h3>
<p>Returns the signed 32-bit integer value of this <a href="qjsvalue.html">QJSValue</a>, using the conversion rules described in <a href="http://www.ecma-international.org/publications/standards/Ecma-262.htm">ECMA-262</a> section 9.5, &quot;ToInt32&quot;.</p>
<p>Note that if this <a href="qjsvalue.html">QJSValue</a> is an object, calling this function has side effects on the script engine, since the engine will call the object's valueOf() function (and possibly <a href="qjsvalue.html#toString">toString</a>()) in an attempt to convert the object to a primitive value (possibly resulting in an uncaught script exception).</p>
<p><b>See also </b><a href="qjsvalue.html#toNumber">toNumber</a>() and <a href="qjsvalue.html#toUInt">toUInt</a>().</p>
<!-- @@@toInt -->
<!-- $$$toNumber[overload1]$$$toNumber -->
<h3 class="fn" id="toNumber"><a name="toNumber"></a><span class="type">double</span> QJSValue::<span class="name">toNumber</span>() const</h3>
<p>Returns the number value of this <a href="qjsvalue.html">QJSValue</a>, as defined in <a href="http://www.ecma-international.org/publications/standards/Ecma-262.htm">ECMA-262</a> section 9.3, &quot;ToNumber&quot;.</p>
<p>Note that if this <a href="qjsvalue.html">QJSValue</a> is an object, calling this function has side effects on the script engine, since the engine will call the object's valueOf() function (and possibly <a href="qjsvalue.html#toString">toString</a>()) in an attempt to convert the object to a primitive value (possibly resulting in an uncaught script exception).</p>
<p><b>See also </b><a href="qjsvalue.html#isNumber">isNumber</a>(), <a href="qjsvalue.html#toInt">toInt</a>(), and <a href="qjsvalue.html#toUInt">toUInt</a>().</p>
<!-- @@@toNumber -->
<!-- $$$toQMetaObject[overload1]$$$toQMetaObject -->
<h3 class="fn" id="toQMetaObject"><a name="toQMetaObject"></a>const <span class="type">QMetaObject</span> *QJSValue::<span class="name">toQMetaObject</span>() const</h3>
<p>* If this <a href="qjsvalue.html">QJSValue</a> is a QMetaObject, returns the QMetaObject pointer * that the <a href="qjsvalue.html">QJSValue</a> represents; otherwise, returns <code>nullptr</code>. * *</p>
<p>This function was introduced in  Qt 5.8.</p>
<p><b>See also </b><a href="qjsvalue.html#isQMetaObject">isQMetaObject</a>().</p>
<!-- @@@toQMetaObject -->
<!-- $$$toQObject[overload1]$$$toQObject -->
<h3 class="fn" id="toQObject"><a name="toQObject"></a><span class="type">QObject</span> *QJSValue::<span class="name">toQObject</span>() const</h3>
<p>If this <a href="qjsvalue.html">QJSValue</a> is a QObject, returns the QObject pointer that the <a href="qjsvalue.html">QJSValue</a> represents; otherwise, returns <code>nullptr</code>.</p>
<p>If the QObject that this <a href="qjsvalue.html">QJSValue</a> wraps has been deleted, this function returns <code>nullptr</code> (i.e&#x2e; it is possible for toQObject() to return <code>nullptr</code> even when <a href="qjsvalue.html#isQObject">isQObject</a>() returns true).</p>
<p><b>See also </b><a href="qjsvalue.html#isQObject">isQObject</a>().</p>
<!-- @@@toQObject -->
<!-- $$$toString[overload1]$$$toString -->
<h3 class="fn" id="toString"><a name="toString"></a><span class="type">QString</span> QJSValue::<span class="name">toString</span>() const</h3>
<p>Returns the string value of this <a href="qjsvalue.html">QJSValue</a>, as defined in <a href="http://www.ecma-international.org/publications/standards/Ecma-262.htm">ECMA-262</a> section 9.8, &quot;ToString&quot;.</p>
<p>Note that if this <a href="qjsvalue.html">QJSValue</a> is an object, calling this function has side effects on the script engine, since the engine will call the object's toString() function (and possibly valueOf()) in an attempt to convert the object to a primitive value (possibly resulting in an uncaught script exception).</p>
<p><b>See also </b><a href="qjsvalue.html#isString">isString</a>().</p>
<!-- @@@toString -->
<!-- $$$toUInt[overload1]$$$toUInt -->
<h3 class="fn" id="toUInt"><a name="toUInt"></a><span class="type">quint32</span> QJSValue::<span class="name">toUInt</span>() const</h3>
<p>Returns the unsigned 32-bit integer value of this <a href="qjsvalue.html">QJSValue</a>, using the conversion rules described in <a href="http://www.ecma-international.org/publications/standards/Ecma-262.htm">ECMA-262</a> section 9.6, &quot;ToUint32&quot;.</p>
<p>Note that if this <a href="qjsvalue.html">QJSValue</a> is an object, calling this function has side effects on the script engine, since the engine will call the object's valueOf() function (and possibly <a href="qjsvalue.html#toString">toString</a>()) in an attempt to convert the object to a primitive value (possibly resulting in an uncaught script exception).</p>
<p><b>See also </b><a href="qjsvalue.html#toNumber">toNumber</a>() and <a href="qjsvalue.html#toInt">toInt</a>().</p>
<!-- @@@toUInt -->
<!-- $$$toVariant[overload1]$$$toVariant -->
<h3 class="fn" id="toVariant"><a name="toVariant"></a><span class="type">QVariant</span> QJSValue::<span class="name">toVariant</span>() const</h3>
<p>Returns the QVariant value of this <a href="qjsvalue.html">QJSValue</a>, if it can be converted to a QVariant; otherwise returns an invalid QVariant. The conversion is performed according to the following table:</p>
<div class="table"><table class="generic">
 <thead><tr class="qt-style"><th >Input Type</th><th >Result</th></tr></thead>
<tr valign="top" class="odd"><td >Undefined</td><td >An invalid QVariant.</td></tr>
<tr valign="top" class="even"><td >Null</td><td >A QVariant containing a null pointer (QMetaType::Nullptr).</td></tr>
<tr valign="top" class="odd"><td >Boolean</td><td >A QVariant containing the value of the boolean.</td></tr>
<tr valign="top" class="even"><td >Number</td><td >A QVariant containing the value of the number.</td></tr>
<tr valign="top" class="odd"><td >String</td><td >A QVariant containing the value of the string.</td></tr>
<tr valign="top" class="even"><td >QVariant Object</td><td >The result is the QVariant value of the object (no conversion).</td></tr>
<tr valign="top" class="odd"><td >QObject Object</td><td >A QVariant containing a pointer to the QObject.</td></tr>
<tr valign="top" class="even"><td >Date Object</td><td >A QVariant containing the date value (<a href="qjsvalue.html#toDateTime">toDateTime</a>()).</td></tr>
<tr valign="top" class="odd"><td >RegExp Object</td><td >A QVariant containing the regular expression value.</td></tr>
<tr valign="top" class="even"><td >Array Object</td><td >The array is converted to a QVariantList. Each element is converted to a QVariant, recursively; cyclic references are not followed.</td></tr>
<tr valign="top" class="odd"><td >Object</td><td >The object is converted to a QVariantMap. Each property is converted to a QVariant, recursively; cyclic references are not followed.</td></tr>
</table></div>
<p><b>See also </b><a href="qjsvalue.html#isVariant">isVariant</a>().</p>
<!-- @@@toVariant -->
<!-- $$$operator=[overload1]$$$operator=QJSValue&& -->
<h3 class="fn" id="operator-eq"><a name="operator-eq"></a><span class="type"><a href="qjsvalue.html#QJSValue">QJSValue</a></span> &amp;QJSValue::<span class="name">operator=</span>(<span class="type"><a href="qjsvalue.html#QJSValue">QJSValue</a></span> &amp;&amp;<i>other</i>)</h3>
<p>Move-assigns <i>other</i> to this <a href="qjsvalue.html">QJSValue</a> object.</p>
<!-- @@@operator= -->
<!-- $$$operator=$$$operator=constQJSValue& -->
<h3 class="fn" id="operator-eq-1"><a name="operator-eq-1"></a><span class="type"><a href="qjsvalue.html#QJSValue">QJSValue</a></span> &amp;QJSValue::<span class="name">operator=</span>(const <span class="type"><a href="qjsvalue.html#QJSValue">QJSValue</a></span> &amp;<i>other</i>)</h3>
<p>Assigns the <i>other</i> value to this <a href="qjsvalue.html">QJSValue</a>.</p>
<p>Note that if <i>other</i> is an object (<a href="qjsvalue.html#isObject">isObject</a>() returns true), only a reference to the underlying object will be assigned; the object itself will not be copied.</p>
<!-- @@@operator= -->
</div>
<div class="relnonmem">
<h2>Related Non-Members</h2>
<!-- $$$QJSValueList -->
<h3 class="fn" id="QJSValueList-typedef"><a name="QJSValueList-typedef"></a>typedef <span class="name">QJSValueList</span></h3>
<p>This is a typedef for a QList&lt;<a href="qjsvalue.html">QJSValue</a>&gt;.</p>
<!-- @@@QJSValueList -->
</div>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2019 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br/>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br/>    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. </p>
</div>
</body>
</html>