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 * | 对象 () 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 ) |
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" ^
注意, Qt Quick 1 version is named QDeclarativeError
另请参阅 QQuickView::errors () 和 QQmlComponent::errors ().
Creates an empty error object.
创建副本为 other .
Returns the error column number.
另请参阅 setColumn ().
Returns the error description.
另请参阅 setDescription ().
Returns true if this error is valid, otherwise false.
Returns the error line number.
另请参阅 setLine ().
Returns the message type.
该函数在 Qt 5.9 引入。
另请参阅 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.
另请参阅 setObject ().
Sets the error column 编号。
另请参阅 column ().
Sets the error description .
另请参阅 description ().
Sets the error line 编号。
另请参阅 line ().
设置 messageType for this message. The message type determines which QDebug handlers are responsible for recieving the message.
该函数在 Qt 5.9 引入。
另请参阅 messageType ().
Sets the nearest object where this error occurred.
另请参阅 对象 ().
设置 url for the file that caused this error.
另请参阅 url ().
Returns the error as a human readable string.
Returns the url for the file that caused this error.
另请参阅 setUrl ().
赋值 other to this error object.
Outputs a human readable version of error to debug .