The QQmlError class encapsulates a QML error. More...
Header: | #include <QQmlError> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Qml) target_link_libraries(mytarget PRIVATE Qt6::Qml) |
qmake: | QT += qml |
Since: | Qt 5.0 |
QQmlError(const QQmlError &other) | |
QQmlError() | |
QQmlError & | operator=(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 |
QDebug | operator<<(QDebug debug, const QQmlError &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" ^
See also QQuickView::errors() and QQmlComponent::errors().
Creates a copy of other.
Creates an empty error object.
Assigns other to this error object.
Returns the error column number.
See also setColumn().
Returns the error description.
See also setDescription().
Returns true if this error is valid, otherwise false.
Returns the error line number.
See also setLine().
[since 5.9]
QtMsgType QQmlError::messageType() constReturns the message type.
This function was introduced in Qt 5.9.
See also setMessageType().
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().
Sets the error column number.
See also column().
Sets the error description.
See also description().
Sets the error line number.
See also line().
[since 5.9]
void QQmlError::setMessageType(QtMsgType
messageType)Sets the messageType for this message. The message type determines which QDebug handlers are responsible for receiving the message.
This function was introduced in Qt 5.9.
See also messageType().
Sets the nearest object where this error occurred.
See also object().
Sets the url for the file that caused this error.
See also url().
Returns the error as a human readable string.
Returns the url for the file that caused this error.
See also setUrl().