QQmlInfo Class
QQmlInfo 类允许记录 QML 相关信息。更多
Header: | #include <QQmlInfo> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Qml) target_link_libraries(mytarget PRIVATE Qt6::Qml) |
qmake: | QT += qml |
继承: | QDebug |
相关非成员
QQmlInfo | qmlDebug(const QObject *object) |
QQmlInfo | qmlInfo(const QObject *object) |
QQmlInfo | qmlWarning(const QObject *object) |
另请参阅 qmlDebug,qmlInfo, 和qmlWarning 。
相关非成员
QQmlInfo qmlDebug(const QObject *object)
打印调试信息,包括指定 QMLobject 的文件和行号。
当 QML 类型产生日志信息时,如果它们包含 QML 文件和特定实例实例化的行号,就能提高可追溯性。
要包含文件和行号,必须传递一个对象。如果该实例没有文件和行号(要么 QML 引擎没有实例化该实例,要么位置信息被禁用),就会使用 "未知位置"(unknown location)来代替。
例如
qmlDebug(object) << "Internal state: 42";
打印
QML MyCustomType (unknown location): Internal state: 42
另请参阅 qmlInfo 和qmlWarning 。
QQmlInfo qmlInfo(const QObject *object)
打印信息,包括指定 QMLobject 的文件和行号。
当 QML 类型产生日志信息时,如果这些信息包括特定实例实例化的 QML 文件和行号,就能提高可追溯性。
要包含文件和行号,必须传递一个对象。如果该实例没有文件和行号(要么 QML 引擎没有实例化该实例,要么位置信息被禁用),就会使用 "未知位置"(unknown location)来代替。
例如
qmlInfo(object) << tr("component property is a write-once property");
打印
QML MyCustomType (unknown location): component property is a write-once property
注意: 在 Qt 5.9 之前的版本中,qmlInfo 使用 warningQtMsgType 报告信息。对于 Qt 5.9 及以上版本,qmlInfo 使用 infoQtMsgType 。要发送警告,请使用qmlWarning 。
另请参阅 qmlDebug 和qmlWarning 。
QQmlInfo qmlWarning(const QObject *object)
打印警告信息,包括指定 QMLobject 的文件和行号。
当 QML 类型产生日志信息时,如果包含 QML 文件和特定实例实例化的行号,就能提高可追溯性。
要包含文件和行号,必须传递一个对象。如果该实例没有文件和行号(要么 QML 引擎没有实例化该实例,要么位置信息被禁用),就会使用 "未知位置"(unknown location)来代替。
例如
qmlInfo(object) << tr("property cannot be set to 0");
打印
QML MyCustomType (unknown location): property cannot be set to 0
© 2025 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.