QQmlError Class

The QQmlError class encapsulates a QML error. 更多...

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

公共函數

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 & 描述 )
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 )

詳細描述

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
					

可以使用 qDebug (), qInfo (),或 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"
           ^
					

另請參閱 QQuickView::errors () 和 QQmlComponent::errors ().

成員函數文檔編製

QQmlError:: QQmlError ()

Creates an empty error object.

QQmlError:: QQmlError (const QQmlError & other )

創建副本為 other .

int QQmlError:: column () const

Returns the error column number.

另請參閱 setColumn ().

QString QQmlError:: description () const

Returns the error description.

另請參閱 setDescription ().

bool QQmlError:: isValid () const

Returns true if this error is valid, otherwise false.

int QQmlError:: line () const

Returns the error line number.

另請參閱 setLine ().

QtMsgType QQmlError:: messageType () const

Returns the message type.

該函數在 Qt 5.9 引入。

另請參閱 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.

另請參閱 setObject ().

void QQmlError:: setColumn ( int column )

Sets the error column 編號。

另請參閱 column ().

void QQmlError:: setDescription (const QString & 描述 )

Sets the error 描述 .

另請參閱 description ().

void QQmlError:: setLine ( int line )

Sets the error line 編號。

另請參閱 line ().

void QQmlError:: setMessageType ( QtMsgType messageType )

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

該函數在 Qt 5.9 引入。

另請參閱 messageType ().

void QQmlError:: setObject ( QObject * object )

Sets the nearest object where this error occurred.

另請參閱 object ().

void QQmlError:: setUrl (const QUrl & url )

設置 url for the file that caused this error.

另請參閱 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.

另請參閱 setUrl ().

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

賦值 other to this error object.

相關非成員

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

Outputs a human readable version of error to debug .