Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QQmlError Class Reference

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

#include <qqmlerror.h>

+ Collaboration diagram for QQmlError:

Public Member Functions

 QQmlError ()
 Creates an empty error object.
 
 QQmlError (const QQmlError &)
 Creates a copy of other.
 
 QQmlError (QQmlError &&other) noexcept
 
QQmlErroroperator= (const QQmlError &)
 Assigns other to this error object.
 
 ~QQmlError ()
 
void swap (QQmlError &other)
 
bool isValid () const
 Returns true if this error is valid, otherwise false.
 
QUrl url () const
 Returns the url for the file that caused this error.
 
void setUrl (const QUrl &)
 Sets the url for the file that caused this error.
 
QString description () const
 Returns the error description.
 
void setDescription (const QString &)
 Sets the error description.
 
int line () const
 Returns the error line number.
 
void setLine (int)
 Sets the error line number.
 
int column () const
 Returns the error column number.
 
void setColumn (int)
 Sets the error column number.
 
QObjectobject () const
 Returns the nearest object where this error occurred.
 
void setObject (QObject *)
 Sets the nearest object where this error occurred.
 
QtMsgType messageType () const
 
void setMessageType (QtMsgType messageType)
 
QString toString () const
 Returns the error as a human readable string.
 

Friends

bool Q_QML_EXPORT operator== (const QQmlError &a, const QQmlError &b)
 

Related Symbols

(Note that these are not member symbols.)

QDebug operator<< (QDebug debug, const QQmlError &error)
 Outputs a human readable version of error to debug.
 

Detailed Description

The QQmlError class encapsulates a QML error.

Since
5.0 \inmodule QtQml

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:

QFile file
[0]

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.

y: "hello"
^
GLint y
See also
QQuickView::errors(), QQmlComponent::errors()

Definition at line 17 of file qqmlerror.h.

Constructor & Destructor Documentation

◆ QQmlError() [1/3]

QQmlError::QQmlError ( )

Creates an empty error object.

Definition at line 63 of file qqmlerror.cpp.

◆ QQmlError() [2/3]

QQmlError::QQmlError ( const QQmlError & other)

Creates a copy of other.

Definition at line 71 of file qqmlerror.cpp.

References other().

+ Here is the call graph for this function:

◆ QQmlError() [3/3]

QQmlError::QQmlError ( QQmlError && other)
inlinenoexcept

Definition at line 22 of file qqmlerror.h.

◆ ~QQmlError()

QQmlError::~QQmlError ( )

Definition at line 101 of file qqmlerror.cpp.

Member Function Documentation

◆ column()

int QQmlError::column ( ) const

Returns the error column number.

Definition at line 177 of file qqmlerror.cpp.

References QQmlErrorPrivate::column.

Referenced by setColumn(), and toString().

+ Here is the caller graph for this function:

◆ description()

QString QQmlError::description ( ) const

Returns the error description.

Definition at line 137 of file qqmlerror.cpp.

References QQmlErrorPrivate::message.

Referenced by QQmlComponent::errorString(), setDescription(), and toString().

+ Here is the caller graph for this function:

◆ isValid()

bool QQmlError::isValid ( ) const

Returns true if this error is valid, otherwise false.

Definition at line 109 of file qqmlerror.cpp.

Referenced by QQmlDelayedError::isValid().

+ Here is the caller graph for this function:

◆ line()

int QQmlError::line ( ) const

Returns the error line number.

Definition at line 157 of file qqmlerror.cpp.

References QQmlErrorPrivate::line.

Referenced by QQmlComponent::errorString(), setLine(), and toString().

+ Here is the caller graph for this function:

◆ messageType()

QtMsgType QQmlError::messageType ( ) const
Since
5.9

Returns the message type.

Definition at line 222 of file qqmlerror.cpp.

References QtWarningMsg, and QQmlErrorPrivate::type.

Referenced by setMessageType().

+ Here is the caller graph for this function:

◆ object()

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.

Definition at line 200 of file qqmlerror.cpp.

References QQmlErrorPrivate::object.

Referenced by setObject().

+ Here is the caller graph for this function:

◆ operator=()

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

Assigns other to this error object.

Definition at line 80 of file qqmlerror.cpp.

References QQmlErrorPrivate::column, QQmlErrorPrivate::line, QQmlErrorPrivate::message, QQmlErrorPrivate::object, other(), QQmlErrorPrivate::type, and QQmlErrorPrivate::url.

+ Here is the call graph for this function:

◆ setColumn()

void QQmlError::setColumn ( int column)

Sets the error column number.

Definition at line 187 of file qqmlerror.cpp.

References QQmlErrorPrivate::column, and column().

Referenced by QQmlPropertyBindingJS::expressionChanged(), QQmlDataBlob::setError(), and QQmlDelayedError::setErrorLocation().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setDescription()

void QQmlError::setDescription ( const QString & description)

Sets the error description.

Definition at line 147 of file qqmlerror.cpp.

References description(), and QQmlErrorPrivate::message.

Referenced by QQmlPropertyBindingJS::expressionChanged(), QV4::generateWarning(), QQmlVMEMetaObject::metaCall(), QQmlImportInstance::resolveType(), ListModel::set(), QQmlDataBlob::setError(), QQmlDataBlob::setError(), QQmlDelayedError::setErrorDescription(), and QQmlPropertyCacheCreator< ObjectContainer >::verifyNoICCycle().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setLine()

void QQmlError::setLine ( int line)

Sets the error line number.

Definition at line 167 of file qqmlerror.cpp.

References QQmlErrorPrivate::line, and line().

Referenced by QQmlPropertyBindingJS::expressionChanged(), QQmlDataBlob::setError(), and QQmlDelayedError::setErrorLocation().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setMessageType()

void QQmlError::setMessageType ( QtMsgType messageType)
Since
5.9

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

Definition at line 235 of file qqmlerror.cpp.

References messageType(), and QQmlErrorPrivate::type.

+ Here is the call graph for this function:

◆ setObject()

void QQmlError::setObject ( QObject * object)

Sets the nearest object where this error occurred.

Definition at line 210 of file qqmlerror.cpp.

References QQmlErrorPrivate::object, and object().

Referenced by QQmlPropertyBindingJS::expressionChanged(), and QQmlDelayedError::setErrorObject().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setUrl()

void QQmlError::setUrl ( const QUrl & url)

Sets the url for the file that caused this error.

Definition at line 127 of file qqmlerror.cpp.

References QQmlErrorPrivate::url, and url().

Referenced by QQmlPropertyBindingJS::expressionChanged(), QQmlDataBlob::setError(), QQmlDataBlob::setError(), and QQmlDelayedError::setErrorLocation().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ swap()

void QQmlError::swap ( QQmlError & other)
inline

Definition at line 30 of file qqmlerror.h.

References d, other(), and qt_ptr_swap().

+ Here is the call graph for this function:

◆ toString()

QString QQmlError::toString ( ) const

Returns the error as a human readable string.

Definition at line 245 of file qqmlerror.cpp.

References column(), description(), QUrl::isEmpty(), QString::isEmpty(), QUrl::isLocalFile(), line(), QString::number(), QUrl::path(), QUrl::toString(), and url().

Referenced by QQmlDataBlob::setError().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ url()

QUrl QQmlError::url ( ) const

Returns the url for the file that caused this error.

Definition at line 117 of file qqmlerror.cpp.

References QQmlErrorPrivate::url.

Referenced by QQmlComponent::errorString(), setUrl(), and toString().

+ Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ operator<<()

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

Outputs a human readable version of error to debug.

Definition at line 282 of file qqmlerror.cpp.

References QByteArray::append(), QString::at(), ch, QByteArray::constData(), debug, error, file, i, line, qMax(), qMin(), qPrintable, QIODeviceBase::ReadOnly, QByteArray::reserve(), QUrl::scheme(), QString::size(), QString::split(), QString::toLocal8Bit(), url, and QQmlFile::urlToLocalFileOrQrc().

+ Here is the call graph for this function:

◆ operator==

bool Q_QML_EXPORT operator== ( const QQmlError & a,
const QQmlError & b )
friend

Definition at line 270 of file qqmlerror.cpp.


The documentation for this class was generated from the following files: