QQmlError Class

The QQmlError class encapsulates a QML error. More...

Header: #include <QQmlError>
qmake: QT += qml
Since: Qt 5.0

Public Functions

QQmlError()
QQmlError(const QQmlError &other)
int column() const
QString description() const
bool isValid() const
int line() const
QtMsgType messageType() const
QObject *object() const
void setColumn(int column)
void setDescription(const QString &description)
void setLine(int line)
void setMessageType(QtMsgType messageType)
void setObject(QObject *object)
void setUrl(const QUrl &url)
QString toString() const
QUrl url() const
QQmlError &operator=(const QQmlError &other)
QDebug operator<<(QDebug debug, const QQmlError &error)

Detailed Description

The QQmlError class encapsulates a QML error.

QQmlError includes a textual description of the error, as well as location information (the file, line, and column). The toString() method creates a single-line, human-readable string containing all of this information, for example:

file:///home/user/test.qml:7:8: Invalid property assignment: double expected

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.

file:///home/user/test.qml:7:8: Invalid property assignment: double expected
        y: "hello"
           ^

Note that the Qt Quick 1 version is named QDeclarativeError

See also QQuickView::errors() and QQmlComponent::errors().

Member Function Documentation

QQmlError::QQmlError()

Creates an empty error object.

QQmlError::QQmlError(const QQmlError &other)

Creates a copy of other.

int QQmlError::column() const

Returns the error column number.

See also setColumn().

QString QQmlError::description() const

Returns the error description.

See also setDescription().

bool QQmlError::isValid() const

Returns true if this error is valid, otherwise false.

int QQmlError::line() const

Returns the error line number.

See also setLine().

QtMsgType QQmlError::messageType() const

Returns the message type.

This function was introduced in Qt 5.9.

See also setMessageType().

QObject *QQmlError::object() const

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.

See also setObject().

void QQmlError::setColumn(int column)

Sets the error column number.

See also column().

void QQmlError::setDescription(const QString &description)

Sets the error description.

See also description().

void QQmlError::setLine(int line)

Sets the error line number.

See also line().

void QQmlError::setMessageType(QtMsgType messageType)

Sets the messageType for this message. The message type determines which QDebug handlers are responsible for recieving the message.

This function was introduced in Qt 5.9.

See also messageType().

void QQmlError::setObject(QObject *object)

Sets the nearest object where this error occurred.

See also object().

void QQmlError::setUrl(const QUrl &url)

Sets the url for the file that caused this error.

See also url().

QString QQmlError::toString() const

Returns the error as a human readable string.

QUrl QQmlError::url() const

Returns the url for the file that caused this error.

See also setUrl().

QQmlError &QQmlError::operator=(const QQmlError &other)

Assigns other to this error object.

Related Non-Members

QDebug operator<<(QDebug debug, const QQmlError &error)

Outputs a human readable version of error to debug.

© 2017 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.