<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <!-- qqmlscriptstring.cpp --> <title>QQmlScriptString Class | Qt QML 5.11</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 ><a href="../qtdoc/index.html">Qt 5.11</a></td><td ><a href="qtqml-index.html">Qt QML</a></td><td ><a href="qtqml-module.html">C++ Classes</a></td><td >QQmlScriptString</td></tr></table><table class="buildversion"><tr> <td id="buildversion" width="100%" align="right">Qt 5.11.2 Reference Documentation</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-functions">Public Functions</a></li> <li class="level1"><a href="#details">Detailed Description</a></li> </ul> </div> <div class="sidebar-content" id="sidebar-content"></div></div> <h1 class="title">QQmlScriptString Class</h1> <!-- $$$QQmlScriptString-brief --> <p>The <a href="qqmlscriptstring.html">QQmlScriptString</a> class encapsulates a script and its context. <a href="#details">More...</a></p> <!-- @@@QQmlScriptString --> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign"> <span class="preprocessor">#include <QQmlScriptString></span> </td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += qml</td></tr></table></div><ul> <li><a href="qqmlscriptstring-members.html">List of all members, including inherited members</a></li> </ul> <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="qqmlscriptstring.html#QQmlScriptString">QQmlScriptString</a></b>()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qqmlscriptstring.html#QQmlScriptString-1">QQmlScriptString</a></b>(const QQmlScriptString &<i>other</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qqmlscriptstring.html#booleanLiteral">booleanLiteral</a></b>(bool *<i>ok</i>) const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qqmlscriptstring.html#isEmpty">isEmpty</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qqmlscriptstring.html#isNullLiteral">isNullLiteral</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qqmlscriptstring.html#isUndefinedLiteral">isUndefinedLiteral</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> qreal </td><td class="memItemRight bottomAlign"><b><a href="qqmlscriptstring.html#numberLiteral">numberLiteral</a></b>(bool *<i>ok</i>) const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qqmlscriptstring.html#stringLiteral">stringLiteral</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qqmlscriptstring.html#operator-not-eq">operator!=</a></b>(const QQmlScriptString &<i>other</i>) const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QQmlScriptString &</td><td class="memItemRight bottomAlign"><b><a href="qqmlscriptstring.html#operator-eq">operator=</a></b>(const QQmlScriptString &<i>other</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qqmlscriptstring.html#operator-eq-eq">operator==</a></b>(const QQmlScriptString &<i>other</i>) const</td></tr> </table></div> <a name="details"></a> <!-- $$$QQmlScriptString-description --> <div class="descr"> <h2 id="details">Detailed Description</h2> <p>The <a href="qqmlscriptstring.html">QQmlScriptString</a> class encapsulates a script and its context.</p> <p><a href="qqmlscriptstring.html">QQmlScriptString</a> is used to create <a href="../qtcore/qobject.html">QObject</a> properties that accept a script "assignment" from QML.</p> <p>Normally, the following QML would result in a binding being established for the <code>script</code> property; i.e. <code>script</code> would be assigned the value obtained from running <code>myObj.value = Math.max(myValue, 100)</code></p> <pre class="qml"> <span class="type">MyType</span> { <span class="name">script</span>: <span class="name">myObj</span>.<span class="name">value</span> <span class="operator">=</span> <span class="name">Math</span>.<span class="name">max</span>(<span class="name">myValue</span>, <span class="number">100</span>) } </pre> <p>If instead the property had a type of <a href="qqmlscriptstring.html">QQmlScriptString</a>, the script itself -- <i>myObj.value = Math.max(myValue, 100)</i> -- would be passed to the <code>script</code> property and the class could choose how to handle it. Typically, the class will evaluate the script at some later time using a <a href="qqmlexpression.html">QQmlExpression</a>.</p> <pre class="cpp"> <span class="type"><a href="qqmlexpression.html">QQmlExpression</a></span> expr(scriptString); expr<span class="operator">.</span>evaluate(); </pre> </div> <p><b>See also </b><a href="qqmlexpression.html">QQmlExpression</a>.</p> <!-- @@@QQmlScriptString --> <div class="func"> <h2>Member Function Documentation</h2> <!-- $$$QQmlScriptString[overload1]$$$QQmlScriptString --> <h3 class="fn" id="QQmlScriptString"><a name="QQmlScriptString"></a>QQmlScriptString::<span class="name">QQmlScriptString</span>()</h3> <p>Constructs an empty instance.</p> <!-- @@@QQmlScriptString --> <!-- $$$QQmlScriptString$$$QQmlScriptStringconstQQmlScriptString& --> <h3 class="fn" id="QQmlScriptString-1"><a name="QQmlScriptString-1"></a>QQmlScriptString::<span class="name">QQmlScriptString</span>(const <span class="type"><a href="qqmlscriptstring.html#QQmlScriptString">QQmlScriptString</a></span> &<i>other</i>)</h3> <p>Copies <i>other</i>.</p> <!-- @@@QQmlScriptString --> <!-- $$$booleanLiteral[overload1]$$$booleanLiteralbool* --> <h3 class="fn" id="booleanLiteral"><a name="booleanLiteral"></a><span class="type">bool</span> QQmlScriptString::<span class="name">booleanLiteral</span>(<span class="type">bool</span> *<i>ok</i>) const</h3> <p>If the content of the <a href="qqmlscriptstring.html">QQmlScriptString</a> is a boolean literal, returns the boolean value and sets <i>ok</i> to true. Otherwise returns false and sets <i>ok</i> to false.</p> <!-- @@@booleanLiteral --> <!-- $$$isEmpty[overload1]$$$isEmpty --> <h3 class="fn" id="isEmpty"><a name="isEmpty"></a><span class="type">bool</span> QQmlScriptString::<span class="name">isEmpty</span>() const</h3> <p>Returns whether the <a href="qqmlscriptstring.html">QQmlScriptString</a> is empty.</p> <!-- @@@isEmpty --> <!-- $$$isNullLiteral[overload1]$$$isNullLiteral --> <h3 class="fn" id="isNullLiteral"><a name="isNullLiteral"></a><span class="type">bool</span> QQmlScriptString::<span class="name">isNullLiteral</span>() const</h3> <p>Returns whether the content of the <a href="qqmlscriptstring.html">QQmlScriptString</a> is the <code>null</code> literal.</p> <!-- @@@isNullLiteral --> <!-- $$$isUndefinedLiteral[overload1]$$$isUndefinedLiteral --> <h3 class="fn" id="isUndefinedLiteral"><a name="isUndefinedLiteral"></a><span class="type">bool</span> QQmlScriptString::<span class="name">isUndefinedLiteral</span>() const</h3> <p>Returns whether the content of the <a href="qqmlscriptstring.html">QQmlScriptString</a> is the <code>undefined</code> literal.</p> <!-- @@@isUndefinedLiteral --> <!-- $$$numberLiteral[overload1]$$$numberLiteralbool* --> <h3 class="fn" id="numberLiteral"><a name="numberLiteral"></a><span class="type"><a href="../qtcore/qtglobal.html#qreal-typedef">qreal</a></span> QQmlScriptString::<span class="name">numberLiteral</span>(<span class="type">bool</span> *<i>ok</i>) const</h3> <p>If the content of the <a href="qqmlscriptstring.html">QQmlScriptString</a> is a number literal, returns that number and sets <i>ok</i> to true. Otherwise returns 0.0 and sets <i>ok</i> to false.</p> <!-- @@@numberLiteral --> <!-- $$$stringLiteral[overload1]$$$stringLiteral --> <h3 class="fn" id="stringLiteral"><a name="stringLiteral"></a><span class="type"><a href="../qtcore/qstring.html">QString</a></span> QQmlScriptString::<span class="name">stringLiteral</span>() const</h3> <p>If the content of the <a href="qqmlscriptstring.html">QQmlScriptString</a> is a string literal, returns that string. Otherwise returns a null <a href="../qtcore/qstring.html">QString</a>.</p> <!-- @@@stringLiteral --> <!-- $$$operator!=[overload1]$$$operator!=constQQmlScriptString& --> <h3 class="fn" id="operator-not-eq"><a name="operator-not-eq"></a><span class="type">bool</span> QQmlScriptString::<span class="name">operator!=</span>(const <span class="type"><a href="qqmlscriptstring.html#QQmlScriptString">QQmlScriptString</a></span> &<i>other</i>) const</h3> <p>Returns <code>true</code> if this and the <i>other</i> <a href="qqmlscriptstring.html">QQmlScriptString</a> objects are different.</p> <p><b>See also </b><a href="qqmlscriptstring.html#operator-eq-eq">operator==</a>().</p> <!-- @@@operator!= --> <!-- $$$operator=[overload1]$$$operator=constQQmlScriptString& --> <h3 class="fn" id="operator-eq"><a name="operator-eq"></a><span class="type"><a href="qqmlscriptstring.html#QQmlScriptString">QQmlScriptString</a></span> &QQmlScriptString::<span class="name">operator=</span>(const <span class="type"><a href="qqmlscriptstring.html#QQmlScriptString">QQmlScriptString</a></span> &<i>other</i>)</h3> <p>Assigns <i>other</i> to this.</p> <!-- @@@operator= --> <!-- $$$operator==[overload1]$$$operator==constQQmlScriptString& --> <h3 class="fn" id="operator-eq-eq"><a name="operator-eq-eq"></a><span class="type">bool</span> QQmlScriptString::<span class="name">operator==</span>(const <span class="type"><a href="qqmlscriptstring.html#QQmlScriptString">QQmlScriptString</a></span> &<i>other</i>) const</h3> <p>Returns <code>true</code> if this and the <i>other</i> <a href="qqmlscriptstring.html">QQmlScriptString</a> objects are equal.</p> <p><b>See also </b><a href="qqmlscriptstring.html#operator-not-eq">operator!=</a>().</p> <!-- @@@operator== --> </div> </div> </div> </div> </div> </div> <div class="footer"> <p> <acronym title="Copyright">©</acronym> 2018 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>