このページでは

QQmlError Class

QQmlError クラスは、QML のエラーをカプセル化しています。詳細...

ヘッダー: #include <QQmlError>
CMake: find_package(Qt6 REQUIRED COMPONENTS Qml)
target_link_libraries(mytarget PRIVATE Qt6::Qml)
qmake: QT += qml

パブリック関数

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)

詳細な説明

QQmlErrorには、エラーの説明文に加え、位置情報(ファイル、行、列)が含まれています。toString() メソッドは、これらの情報をすべて含む、人間が読みやすい1行の文字列を作成します。例:

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

qDebug()、qInfo()、またはqWarning() を使用して、エラーをコンソールに出力できます。このメソッドは、エラーで指定されたファイルを開こうとし、追加のコンテキスト情報を含めます。

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

QQuickView::errors() およびQQmlComponent::errors()も参照してください 。

メンバ関数のドキュメント

QQmlError::QQmlError()

空のエラーオブジェクトを作成します。

QQmlError::QQmlError(const QQmlError &other)

other のコピーを作成します。

int QQmlError::column() const

エラーの列番号を返します。

setColumn()も参照してください 。

QString QQmlError::description() const

エラーの説明を返します。

setDescription()も参照してください 。

bool QQmlError::isValid() const

このエラーが有効な場合は true を返し、そうでない場合は false を返します。

int QQmlError::line() const

エラーの行番号を返します。

setLine()も参照してください 。

QtMsgType QQmlError::messageType() const

メッセージのタイプを返します。

setMessageType()も参照してください 。

QObject *QQmlError::object() const

このエラーが発生した最も近いオブジェクトを返します。バインドされたプロパティ式で発生した例外の場合、この値は、そのプロパティが属するオブジェクトに設定されます。それ以外のすべての例外では、0 になります。

setObject()も参照してください 。

void QQmlError::setColumn(int column)

column のエラー番号を設定します。

column()も参照してください 。

void QQmlError::setDescription(const QString &description)

description のエラーを設定します。

description()も参照してください 。

void QQmlError::setLine(int line)

line のエラー番号を設定します。

line()も参照してください 。

void QQmlError::setMessageType(QtMsgType messageType)

このメッセージのmessageType を設定します。メッセージタイプによって、どのQDebug ハンドラがメッセージの受信を担当するかが決まります。

「messageType()」も参照してください 。

void QQmlError::setObject(QObject *object)

このエラーが発生した最も近いobject を設定します。

object()も参照してください 。

void QQmlError::setUrl(const QUrl &url)

このエラーの原因となったファイルのurl を設定します。

url()も参照してください 。

QString QQmlError::toString() const

エラーを人間が読みやすい文字列として返します。

QUrl QQmlError::url() const

このエラーの原因となったファイルのURLを返します。

setUrl()も参照してください 。

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

このエラーオブジェクトにother を割り当てます。

関連する非メンバー

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

error の人間が読みやすい形式のバージョンをdebug に出力します。

© 2026 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.