QtQml Namespace

Provides functions for producing logging messages for QML types. 更多...

头: #include <QtQml>
qmake: QT += qml

    函数

    QQmlInfo qmlDebug (const QObject * object )
    QQmlInfo qmlInfo (const QObject * object )
    QQmlInfo qmlWarning (const QObject * object )

    详细描述

    函数文档编制

    QQmlInfo QtQml:: qmlDebug (const QObject * object )

    Prints debug messages that include the file and line number for the specified QML object .

    When QML types produce logging messages, it improves traceability if they include the QML file and line number on which the particular instance was instantiated.

    To include the file and line number, an object must be passed. If the file and line number is not available for that instance (either it was not instantiated by the QML engine or location information is disabled), "unknown location" will be used instead. For example,

    qmlDebug(object) << "Internal state: 42";
    					

    prints

    QML MyCustomType (unknown location): Internal state: 42
    					

    该函数在 Qt 5.9 引入。

    另请参阅 QtQml::qmlInfo and QtQml::qmlWarning .

    QQmlInfo QtQml:: qmlInfo (const QObject * object )

    Prints informational messages that include the file and line number for the specified QML object .

    When QML types produce logging messages, it improves traceability if they include the QML file and line number on which the particular instance was instantiated.

    To include the file and line number, an object must be passed. If the file and line number is not available for that instance (either it was not instantiated by the QML engine or location information is disabled), "unknown location" will be used instead.

    例如,

    qmlInfo(object) << tr("component property is a write-once property");
    					

    prints

    QML MyCustomType (unknown location): component property is a write-once property
    					

    注意: In versions prior to Qt 5.9, qmlInfo reported messages using a warning QtMsgType . For Qt 5.9 and above, qmlInfo uses an info QtMsgType . To send warnings, use qmlWarning .

    另请参阅 QtQml::qmlDebug and QtQml::qmlWarning .

    QQmlInfo QtQml:: qmlWarning (const QObject * object )

    Prints warning messages that include the file and line number for the specified QML object .

    When QML types produce logging messages, it improves traceability if they include the QML file and line number on which the particular instance was instantiated.

    To include the file and line number, an object must be passed. If the file and line number is not available for that instance (either it was not instantiated by the QML engine or location information is disabled), "unknown location" will be used instead.

    例如,

    qmlInfo(object) << tr("property cannot be set to 0");
    					

    prints

    QML MyCustomType (unknown location): property cannot be set to 0
    					

    该函数在 Qt 5.9 引入。

    另请参阅 QtQml::qmlDebug and QtQml::qmlInfo .