<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <!-- qqmlerror.cpp --> <title>QQmlError Class | Qt QML 5.9</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.9</td><td ><a href="qtqml-index.html">Qt QML</a></td><td ><a href="qtqml-module.html">C++ Classes</a></td><td >QQmlError</td></tr></table><table class="buildversion"><tr> <td id="buildversion" width="100%" align="right">Qt 5.9.4 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="#related-non-members">Related Non-Members</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">QQmlError Class</h1> <!-- $$$QQmlError-brief --> <p>The <a href="qqmlerror.html">QQmlError</a> class encapsulates a QML error. <a href="#details">More...</a></p> <!-- @@@QQmlError --> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign"> <span class="preprocessor">#include <QQmlError></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="qqmlerror-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="qqmlerror.html#QQmlError">QQmlError</a></b>()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qqmlerror.html#QQmlError-1">QQmlError</a></b>(const QQmlError &<i>other</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qqmlerror.html#column">column</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qqmlerror.html#description">description</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qqmlerror.html#isValid">isValid</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qqmlerror.html#line">line</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QtMsgType </td><td class="memItemRight bottomAlign"><b><a href="qqmlerror.html#messageType">messageType</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QObject *</td><td class="memItemRight bottomAlign"><b><a href="qqmlerror.html#object">object</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qqmlerror.html#setColumn">setColumn</a></b>(int <i>column</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qqmlerror.html#setDescription">setDescription</a></b>(const QString &<i>description</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qqmlerror.html#setLine">setLine</a></b>(int <i>line</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qqmlerror.html#setMessageType">setMessageType</a></b>(QtMsgType <i>messageType</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qqmlerror.html#setObject">setObject</a></b>(QObject *<i>object</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qqmlerror.html#setUrl">setUrl</a></b>(const QUrl &<i>url</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qqmlerror.html#toString">toString</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QUrl </td><td class="memItemRight bottomAlign"><b><a href="qqmlerror.html#url">url</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QQmlError &</td><td class="memItemRight bottomAlign"><b><a href="qqmlerror.html#operator-eq">operator=</a></b>(const QQmlError &<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"> QDebug </td><td class="memItemRight bottomAlign"><b><a href="qqmlerror.html#operator-lt-lt">operator<<</a></b>(QDebug <i>debug</i>, const QQmlError &<i>error</i>)</td></tr> </table></div> <a name="details"></a> <!-- $$$QQmlError-description --> <div class="descr"> <h2 id="details">Detailed Description</h2> <p>The <a href="qqmlerror.html">QQmlError</a> class encapsulates a QML error.</p> <p><a href="qqmlerror.html">QQmlError</a> includes a textual description of the error, as well as location information (the file, line, and column). The <a href="qqmlerror.html#toString">toString</a>() method creates a single-line, human-readable string containing all of this information, for example:</p> <pre class="cpp"> file:<span class="comment">///home/user/test.qml:7:8: Invalid property assignment: double expected</span> </pre> <p>You can use qDebug(), qInfo(), or qWarning() to output errors to the console. This method will attempt to open the file indicated by the error and include additional contextual information.</p> <pre class="cpp"> file:<span class="comment">///home/user/test.qml:7:8: Invalid property assignment: double expected</span> y: <span class="string">"hello"</span> <span class="operator">^</span> </pre> <p>Note that the Qt Quick 1 version is named QDeclarativeError</p> </div> <p><b>See also </b>QQuickView::errors() and <a href="qqmlcomponent.html#errors">QQmlComponent::errors</a>().</p> <!-- @@@QQmlError --> <div class="func"> <h2>Member Function Documentation</h2> <!-- $$$QQmlError[overload1]$$$QQmlError --> <h3 class="fn" id="QQmlError"><a name="QQmlError"></a>QQmlError::<span class="name">QQmlError</span>()</h3> <p>Creates an empty error object.</p> <!-- @@@QQmlError --> <!-- $$$QQmlError$$$QQmlErrorconstQQmlError& --> <h3 class="fn" id="QQmlError-1"><a name="QQmlError-1"></a>QQmlError::<span class="name">QQmlError</span>(const <span class="type"><a href="qqmlerror.html#QQmlError">QQmlError</a></span> &<i>other</i>)</h3> <p>Creates a copy of <i>other</i>.</p> <!-- @@@QQmlError --> <!-- $$$column[overload1]$$$column --> <h3 class="fn" id="column"><a name="column"></a><span class="type">int</span> QQmlError::<span class="name">column</span>() const</h3> <p>Returns the error column number.</p> <p><b>See also </b><a href="qqmlerror.html#setColumn">setColumn</a>().</p> <!-- @@@column --> <!-- $$$description[overload1]$$$description --> <h3 class="fn" id="description"><a name="description"></a><span class="type">QString</span> QQmlError::<span class="name">description</span>() const</h3> <p>Returns the error description.</p> <p><b>See also </b><a href="qqmlerror.html#setDescription">setDescription</a>().</p> <!-- @@@description --> <!-- $$$isValid[overload1]$$$isValid --> <h3 class="fn" id="isValid"><a name="isValid"></a><span class="type">bool</span> QQmlError::<span class="name">isValid</span>() const</h3> <p>Returns true if this error is valid, otherwise false.</p> <!-- @@@isValid --> <!-- $$$line[overload1]$$$line --> <h3 class="fn" id="line"><a name="line"></a><span class="type">int</span> QQmlError::<span class="name">line</span>() const</h3> <p>Returns the error line number.</p> <p><b>See also </b><a href="qqmlerror.html#setLine">setLine</a>().</p> <!-- @@@line --> <!-- $$$messageType[overload1]$$$messageType --> <h3 class="fn" id="messageType"><a name="messageType"></a><span class="type">QtMsgType</span> QQmlError::<span class="name">messageType</span>() const</h3> <p>Returns the message type.</p> <p>This function was introduced in Qt 5.9.</p> <p><b>See also </b><a href="qqmlerror.html#setMessageType">setMessageType</a>().</p> <!-- @@@messageType --> <!-- $$$object[overload1]$$$object --> <h3 class="fn" id="object"><a name="object"></a><span class="type">QObject</span> *QQmlError::<span class="name">object</span>() const</h3> <p>Returns the nearest object where this error occurred. Exceptions in bound property expressions set this to the object to which the property belongs. It will be 0 for all other exceptions.</p> <p><b>See also </b><a href="qqmlerror.html#setObject">setObject</a>().</p> <!-- @@@object --> <!-- $$$setColumn[overload1]$$$setColumnint --> <h3 class="fn" id="setColumn"><a name="setColumn"></a><span class="type">void</span> QQmlError::<span class="name">setColumn</span>(<span class="type">int</span> <i>column</i>)</h3> <p>Sets the error <i>column</i> number.</p> <p><b>See also </b><a href="qqmlerror.html#column">column</a>().</p> <!-- @@@setColumn --> <!-- $$$setDescription[overload1]$$$setDescriptionconstQString& --> <h3 class="fn" id="setDescription"><a name="setDescription"></a><span class="type">void</span> QQmlError::<span class="name">setDescription</span>(const <span class="type">QString</span> &<i>description</i>)</h3> <p>Sets the error <i>description</i>.</p> <p><b>See also </b><a href="qqmlerror.html#description">description</a>().</p> <!-- @@@setDescription --> <!-- $$$setLine[overload1]$$$setLineint --> <h3 class="fn" id="setLine"><a name="setLine"></a><span class="type">void</span> QQmlError::<span class="name">setLine</span>(<span class="type">int</span> <i>line</i>)</h3> <p>Sets the error <i>line</i> number.</p> <p><b>See also </b><a href="qqmlerror.html#line">line</a>().</p> <!-- @@@setLine --> <!-- $$$setMessageType[overload1]$$$setMessageTypeQtMsgType --> <h3 class="fn" id="setMessageType"><a name="setMessageType"></a><span class="type">void</span> QQmlError::<span class="name">setMessageType</span>(<span class="type">QtMsgType</span> <i>messageType</i>)</h3> <p>Sets the <i>messageType</i> for this message. The message type determines which QDebug handlers are responsible for recieving the message.</p> <p>This function was introduced in Qt 5.9.</p> <p><b>See also </b><a href="qqmlerror.html#messageType">messageType</a>().</p> <!-- @@@setMessageType --> <!-- $$$setObject[overload1]$$$setObjectQObject* --> <h3 class="fn" id="setObject"><a name="setObject"></a><span class="type">void</span> QQmlError::<span class="name">setObject</span>(<span class="type">QObject</span> *<i>object</i>)</h3> <p>Sets the nearest <i>object</i> where this error occurred.</p> <p><b>See also </b><a href="qqmlerror.html#object">object</a>().</p> <!-- @@@setObject --> <!-- $$$setUrl[overload1]$$$setUrlconstQUrl& --> <h3 class="fn" id="setUrl"><a name="setUrl"></a><span class="type">void</span> QQmlError::<span class="name">setUrl</span>(const <span class="type">QUrl</span> &<i>url</i>)</h3> <p>Sets the <i>url</i> for the file that caused this error.</p> <p><b>See also </b><a href="qqmlerror.html#url">url</a>().</p> <!-- @@@setUrl --> <!-- $$$toString[overload1]$$$toString --> <h3 class="fn" id="toString"><a name="toString"></a><span class="type">QString</span> QQmlError::<span class="name">toString</span>() const</h3> <p>Returns the error as a human readable string.</p> <!-- @@@toString --> <!-- $$$url[overload1]$$$url --> <h3 class="fn" id="url"><a name="url"></a><span class="type">QUrl</span> QQmlError::<span class="name">url</span>() const</h3> <p>Returns the url for the file that caused this error.</p> <p><b>See also </b><a href="qqmlerror.html#setUrl">setUrl</a>().</p> <!-- @@@url --> <!-- $$$operator=[overload1]$$$operator=constQQmlError& --> <h3 class="fn" id="operator-eq"><a name="operator-eq"></a><span class="type"><a href="qqmlerror.html#QQmlError">QQmlError</a></span> &QQmlError::<span class="name">operator=</span>(const <span class="type"><a href="qqmlerror.html#QQmlError">QQmlError</a></span> &<i>other</i>)</h3> <p>Assigns <i>other</i> to this error object.</p> <!-- @@@operator= --> </div> <div class="relnonmem"> <h2>Related Non-Members</h2> <!-- $$$operator<<[overload1]$$$operator<<QDebugconstQQmlError& --> <h3 class="fn" id="operator-lt-lt"><a name="operator-lt-lt"></a><span class="type">QDebug</span> <span class="name">operator<<</span>(<span class="type">QDebug</span> <i>debug</i>, const <span class="type"><a href="qqmlerror.html#QQmlError">QQmlError</a></span> &<i>error</i>)</h3> <p>Outputs a human readable version of <i>error</i> to <i>debug</i>.</p> <!-- @@@operator<< --> </div> </div> </div> </div> </div> </div> <div class="footer"> <p> <acronym title="Copyright">©</acronym> 2017 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>