QQmlInfo Class
QQmlInfo 类可用于记录与 QML 相关的消息。更多内容...
| 头文件: | #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)
打印包含指定 QML 文件名和行号的调试信息object 。
当 QML 类型生成日志消息时,如果其中包含该特定实例被实例化的 QML 文件及行号,将有助于提高可追溯性。
要包含文件和行号,必须传递一个对象。如果该实例没有文件和行号(要么不是由 QML 引擎实例化的,要么位置信息被禁用),则会使用“未知位置”代替。
例如,
qmlDebug(object) << "Internal state: 42";将输出
QML MyCustomType (unknown location): Internal state: 42另请参阅 qmlInfo 和qmlWarning 。
QQmlInfo qmlInfo(const QObject *object)
输出包含指定 QML 文件object 及其行号的信息性消息。
当 QML 类型生成日志消息时,如果其中包含该特定实例被实例化的 QML 文件和行号,将有助于提高可追溯性。
要包含文件和行号,必须传递一个对象。如果该实例没有文件和行号(要么不是由 QML 引擎实例化的,要么位置信息被禁用),则会使用“未知位置”代替。
例如,
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 使用警告QtMsgType 来报告消息。对于 Qt 5.9 及以上版本,qmlInfo 使用 infoQtMsgType 。要发送警告,请使用qmlWarning 。
另请参阅 qmlDebug 和qmlWarning 。
QQmlInfo qmlWarning(const QObject *object)
打印包含指定 QML 文件object 的文件名和行号的警告消息。
当 QML 类型生成日志消息时,如果包含该特定实例被实例化的 QML 文件及其行号,将有助于提高可追溯性。
要包含文件和行号,必须传递一个对象。如果该实例没有文件和行号(要么不是由 QML 引擎实例化的,要么位置信息被禁用),则会使用“未知位置”代替。
例如,
qmlInfo(object) << tr("property cannot be set to 0");将输出
QML MyCustomType (unknown location): property cannot be set to 0© 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.